VB 2008 Data Control

Hey Guys,

I am goin gto sound like a complete numpty now with 2008.

I am just starting to learn VB 2008 in Visual Basic Mode.

I am tryin to do the data controls like the old VB6 (bit of a drag and drop king) but that is about to change i feel.

I  need to know how i would do a select record in code

Best Regards

used to be like
adodc1.recordset = " select * from table where column = '" & control & "'"

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I wouldn't use adodb anymore, but if you are learning vb.net, step over to ado.net

.net tutorials: create, read, update, delete
Lesson 01: Introduction to ADO.NET

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If i was to show you some code, then i would suggest following code to step through records one at a time. Following code retrieves single record and displays it in labels.

Dim dbcon as new SQLConnection(connectionstring)
dim dbcmd as new SQLCommand
dbcmd.connection = dbcon
dbcmd.commandtext = "Select * from Products Where ProductID=" & prodID
dim dbreader as SQLDataReader = dbcmd.executereader
if dbreader.hasrows
   if not isdbnull(dbreader.item("Description")) then
      lblDescription.text = dbreader.item("Description")
   end if
   if not isdbnull(dbreader.item("Price")) then
      lblPrice.text = dbreader.item("Price")
   end if
     messagebox.show "Product not found"
end if

Another approach is to display a number of records using controls such as the DataGridView. I do it this way

dim dTable as new DataTable
dim dbadp as new SQLDataAdapter("Select * From Products Where StockQuanity < 10", connectionstring)
DataGridView1.DataSource = dTable

Hope its useful to you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.