Intellisense For SQL Queries In VB.NET

Hi Guys,
I’ve added a database to one of my projects and I’m wondering how I can get intellisense for them.

Basically I have no idea how I can query the database that I’ve added to the project. I know SQL fairly well, but I don’t know how I can write queries within vb.net and have them display.

I need all the help I can get, so intellisense will probably be invaluable.

Can anyone help me get started writing sql queries in vb.net?

(I should mention that this is for a desktop app, not a web app if that makes any difference).

Also I should mention that I’d be quite happy to use linq to sql.
I hear good things about it, but don’t think I can really get started until I fully understand how to properly connect to and retrieve data from a database.

Thanks for your help.
I’ve had a quick look at the topics you mentioned.
I think I might need some more basic advice as I’m not sure if I’m adding my database correctly.

I went to the database explorer and added my database.
The following appears in MY app.config file:


        <add name="EviewTestConnectionString"
            connectionString="Data Source=.\\SQLEXPRESS;AttachDbFilename=&quot;C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\EviewTest.mdf&quot;;Integrated Security=True;Connect Timeout=30;User Instance=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

I’ve grabbed the following from the msdn site:


Private Sub ReadData(ByVal connectionString As String)
        Dim queryString As String = _
            "SELECT * FROM dbo.doctab;"

        Using connection As New SqlConnection(connectionString)
            Dim command As New SqlCommand(queryString, connection)
            connection.Open()

            Dim reader As SqlDataReader = command.ExecuteReader()

            ' Call Read before accessing data.
            While reader.Read()

                Console.WriteLine(String.Format("{0}, {1}", _
                    reader(0), reader(1)))
            End While

            ' Call Close when done reading.
            reader.Close()
        End Using
    End Sub

What I don’t quite understand is, what am I supposed to put as the connection string?

I’ve used the following:
“Server=STEPHEN-B19D613\SQLEXPRESS;Database=EviewTest;Trusted_Connection=True;”

I believe I’ve connected to the database correctly, i.e. adding it to my project, but actually performing a query is still alluding me.

You need SqlConnection, SqlDataReader for VB sql queries.

You cannot get intellisense for the actual query, unless your using something like Linq 2 Sql or Entity Framework.

The things you will need to query your database are:

SqlConnection, SqlDataReader. Then a way to display the data, which could be any control you like really.

For now do some research on the above. Then you can ask more question on that.

Good luck