Inserting into database LINQ to SQL Visual Basic Visual Studio 2008

291 Views Asked by At

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

1

There are 1 best solutions below

0
On

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"}