简体   繁体   中英

Inserting into database LINQ to SQL Visual Basic Visual Studio 2008

Using SQL Server Management Studio 2012

So i have a text box and a button, I would like to type something into the text box and have it inserted into a specific table when i click the button. Here is what i have so far.

I found something a lot easier to read

 Public Shared Sub InsertDealer(ByVal DealerName As String, _
                                ByVal DealerState As String)

    Dim dc = New DataworldDataContext.DataworldDataContext


    Try

        Dim cust As New tblDealer With {.DealerName = "John", _
 .DealerState = "TX"}
        dc.tblDealers.InsertOnSubmit(cust)
        dc.SubmitChanges()

    Catch ex As Exception
        Throw ex
    End Try

End Sub

error is "tblDealer is not defined"

Thanks

It looks like maybe you need to add the namespace to the tblDealer or us Imports to import the namespace.

Dim cust As New DataworldDataContext.tblDealer With {.DealerName = "John", _
    .DealerState = "TX"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM