EGormly
asked on
Simple selecting records from access table
Visual Studio 2008
Visual basic.net
I am having a very hard time understanding .net vs VB6 or vbscript in terms of selecting records from an access database.
Normally all I need to do is this:
ConStringLoginSQL = "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=c:\mydatabase.mdb"
Set objConn = Server.CreateObject("ADODB .Connectio n")
objConn.ConnectionString = ConStringLoginSQL
objConn.Open
Set objRS = Server.CreateObject("ADODB .Recordset ")
strSQL = "SELECT * FROM TableName"
Set objRS= objConn.execute(strSQL)
While not objRS.eof
MyVariable = objRS("MyField")
objRS.movenext
wend
objRS.close
set objRS=nothing
objConn.close
set objConn=nothing
That allows me to manipulate, store or do whatever with the data individually as I am looping through the records.
With .Net all I can find examples of are loading data in to "datashapes" and "grids" all at once.
I dont understand.. how am I supposed to manipulate data this way?
I do not need to show the data only compare and make calculations and such.
what am I missing here?
Can someone show me how to do it the "old way" with .net
(note, it's Visual studio 2008, not 2003 or 2005)
Visual basic.net
I am having a very hard time understanding .net vs VB6 or vbscript in terms of selecting records from an access database.
Normally all I need to do is this:
ConStringLoginSQL = "Provider=Microsoft.Jet.OL
Set objConn = Server.CreateObject("ADODB
objConn.ConnectionString = ConStringLoginSQL
objConn.Open
Set objRS = Server.CreateObject("ADODB
strSQL = "SELECT * FROM TableName"
Set objRS= objConn.execute(strSQL)
While not objRS.eof
MyVariable = objRS("MyField")
objRS.movenext
wend
objRS.close
set objRS=nothing
objConn.close
set objConn=nothing
That allows me to manipulate, store or do whatever with the data individually as I am looping through the records.
With .Net all I can find examples of are loading data in to "datashapes" and "grids" all at once.
I dont understand.. how am I supposed to manipulate data this way?
I do not need to show the data only compare and make calculations and such.
what am I missing here?
Can someone show me how to do it the "old way" with .net
(note, it's Visual studio 2008, not 2003 or 2005)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent Link, I never came across that one. Perfectly fits my situation.
Glad I could help!
jpaulino
jpaulino
ASKER
Using connection As New OleDbConnection(connection
Dim command As New OleDbCommand(queryString, connection)
connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
While reader.Read()
Console.WriteLine(reader(0
End While
reader.Close()
End Using
thanks for the link and the OleDbCommand.ExecuteReader