• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

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.
0
rtdavid
Asked:
rtdavid
  • 2
1 Solution
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now