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 & "'"
adodc1.refresh.

Open in new window

LVL 2
Benji_Asked:
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.

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

Tutorials:
.net tutorials: create, read, update, delete
http://www.dotnetspider.com/tutorials/DotNet-Tutorial-282.aspx
Lesson 01: Introduction to ADO.NET
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson01.aspx
0

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
CodeCruiserCommented:
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)
dbcon.open
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
   dbreader.read
   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
   ...
else
     messagebox.show "Product not found"
end if
dbreader.close
dbcmd.dispose
dbcon.close
dbcon.dispose


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)
dbadp.fill(dTable)
dbadp.dispose
DataGridView1.DataSource = dTable



Hope its useful to you.
0
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.