Last post May 22, 2008 06:02 PM by mconlisk
May 21, 2008 08:58 PM|mconlisk|LINK
Hello, I am very new to working in vb.net, and I am having trouble getting the value of an item in my database. In VBA I am able to use code to access records in my access database. Like this:
Set db = CurrentDb
strSQL = "Select * From [Table] Where [ something ] = [ something ]"
Set rec = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
Variant = rec("[ something ]").Value
the only part of this I can figure out in VB.net is:
Users.SelectCommand = "SELECT * FROM [Table] WHERE [ something ] = [ something ]"
May 22, 2008 12:24 AM|RicIshay|LINK
fisrt you have to write on top of the page " import System.Data.OleDb "
Dim Mycmd As New OleDb Command(“SELECT * FROM dbo.Customer”, myConnection)Dim myOleDb DataAdapter As New OleDb DataAdapter(Mycmd)Dim mydsCustomer As New DataSet() myOleDb DataAdapter.Fill(mydsCustomer, "Customer")
May 22, 2008 02:57 AM|Mikesdotnetting|LINK
How you do this will generally depend on how many values you want to get, and what you plan to do with them, but basically you have three choices:
Command.ExecuteScalar() to retrieve one value
2. Use Command.ExecuteReader() to retrieve multiple values for read-only, forward-only use (such as printing them to a web page
3. Fill a
DataTable or DataSet using an OleDbDataAdapter if you want to be able to move back and forth through the values, or perform more work on them. A DataSet can be thought of as like an in-memory Excel spreadsheet on steroids. In ASP.NET, this is the least
used option (or should be), whereas in desktop apps, they are used a lot more.
May 22, 2008 06:02 PM|mconlisk|LINK
Thank both of you very much. I do not get a whole lot of time to work on this, but with this information I think I can better complete my task.