i am trying to use a basic command on a database table, following the instruction i found here. This is my first time doing sql stuff, and i am having some issues getting the first line of my 'using' to compile. Here is my code:
Dim sql As String = "SELECT * FROM my_table"
Using cn As SqlConnection(getConnectionString()),cmd As New SqlCommand(sql)
//Do Some Stuff
End Using
The error i get is this:
BC36011: 'Using' resource variable must have an explicit initialization.
I looked at the msdn reference, but cant seem to figure out what im doing wrong. Im using vb .net 4.0. Thanks for the help
Try
Using cn As New SqlConnection(getConnectionString()), _
cmd As New SqlCommand(sql)
//Do Some Stuff
End Using