VB.NET and Database

VB.NET and Database

Page 1 of 1

1 Replies - 4243 Views - Last Post: 28 July 2009 - 07:06 AM Rate Topic: -----

#1 Lemi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-July 09

VB.NET and Database

Post icon  Posted 28 July 2009 - 06:56 AM

Help me by letting me know how to write the codes for searhing records in VB.Net database. :^:
Is This A Good Question/Topic? 0
  • +

Replies To: VB.NET and Database

#2 janne_panne   User is offline

  • WinRT Dev
  • member icon

Reputation: 428
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: VB.NET and Database

Posted 28 July 2009 - 07:06 AM

You should learn to google this kind of information, very easy with just search string like "vb.net read database". With the information you provided we can only guess what you are really trying to do and what should we tell you.

What type is your database? access? sql server? mysql? something else?

Here is a skeleton for reading from the database. It's missing all usings and things like that. Should work with Sql server databases. Might not work with Access.

Dim conn as new SqlConnection("my connection string here")
Dim command as new SqlCommand("Select * from mytable", conn)
conn.Open()
Dim reader as SqlDataReader = command.ExecuteReader()
while(reader.Read())
  Console.WriteLine(reader("mycolumn1") & " and " & reader("mycolumn2))
reader.Close()
conn.Close()


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1