How to retrieve records from table(MS SQL Server) using VB.Net

Im a newbie VB.Net user.

I just want to ask how can i retrieve records from table/database (MS SQL Server).  (I'm already connected with the server)

Please complete the codes including the variables/Type. (SQL Statement please)
And if possible, can u give me a link on VB.net Tutorial.

Thanks.
rtdavidAsked:
Who is Participating?
 
wildcard76Commented:
Hi There,

Try this one, I assume you are familiar with SQL already..

Dim conn As New SqlConnection(SQL_CONNECTION_STRING)
Dim cmd As New SqlCommand("Select * from mytable where recordID > 100", conn)
dim adp as new sqldataadapter(cmd)
dim tbl as new datatable
conn.open
adp.fill(tbl)
conn.close

dim drow as datarow

for each drow in tbl.rows
     messagebox.show(drow("field1"))
     messagebox.show(drow("field2"))
     messagebox.show(drow("field3"))
next


hope this helps


Regards


0
 
rtdavidAuthor Commented:
@wildcard76,

   I got an errors :
      Type SqlConnection is not defined
      Type SqlCommand is not defined
      Type sqldataadapter is not defined

0
 
ctm5Commented:
Put

Imports System.Data.SqlClient

at top of class
0
 
rtdavidAuthor Commented:
Thanks alot for helping...... by the way can u give me a link of site where i can get  a tutorial on VB.Net.???


Thanks again.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.