Solved

Using Microsoft SQL Server on VB.NET

Posted on 2006-11-15
2
191 Views
Last Modified: 2010-04-23
I am building a simple form application that needs to access my Microsoft SQL Server (I'm running 2005 Express Edition).

Alright, I've gotten to the point where I've established the connection to my Visual Basic application now I would like to do a statement like "SELECT * FROM mydb.mytable". How do I do that and what is the best way to look at the results from that query. Code would help. Thank you for the help, I realize this is an easy question for you experts but I'd like a starting point.
0
Comment
Question by:Linky
2 Comments
 
LVL 6

Accepted Solution

by:
riyazthad earned 125 total points
ID: 17952910
       Dim cn As New SqlClient.SqlConnection
        cn.ConnectionString = "Give ur connection string here"
        cn.Open()

        Dim ds As DataSet = New DataSet

        Dim MyAdapter As SqlClient.SqlDataAdapter
        MyAdapter  = New SqlClient.SqlDataAdapter ("select * from mytable", cn)

        MyAdapter.Fill(ds)

        For each dr as DataRow in ds.tables(0).rows
              MessageBox.show(dr("field1"))
              MessageBox.show(dr("field2"))
              MessageBox.show(dr("field3"))
              'You can navigate thru all records here.    
        End For
0
 
LVL 2

Author Comment

by:Linky
ID: 17953155
Nifty. Thanks.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question