Solved

Using Microsoft SQL Server on VB.NET

Posted on 2006-11-15
2
190 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now