M
Mr. B
VB.net and MS Access OLE
Two Questions:
First...
+++++
I've used the Wizard to create my OLE Connection, DataAdapter's and DataSet's
to my MS Access data bases. Is there a way to change the path to the Data
Base files at Run time via Code?
.... OR should I repace the Connections with Manual Code? If so, is the
following Correct?
Dim conStr As String = _
"Provider=Microsoft.JET.OLEDB.4.0;datasource=C:\\TSdata\\ExtraServicesData.mdb"
Dim oleStr As String = "SELECT * FROM tblTimeEntry"
' Create connection object
Dim conn As OleDbConnection1 = New OleDbConnection(conStr)
' Create data adapter object
Dim da As OleDbDataAdapter = New OleDbDataAdapter(oleStr, conn)
' Create a dataset object and fill it
Dim oDataSet As New DataSet( )
da.Fill(oDataSet, "tblTimeEntry")
.... am I missing anything here? Cause I have tried it and the FILL line gets
an error
Second...
++++++++
If I've a SELECT in my DataAdapter and that has a filter like:
WHERE (User = ?)
Then I run the following.
daUserData.SelectCommand.Parameters(0).Value = UserID
daUserData.Fill(DsUserData.tblTimeEntry)
This work OK... what I'd like to know is IF there is a way to have "UserID" as
a global value instead of a filter string? In other words, I'ld like to use
the above for both filtering my data... and... selecting it all without a
filter. Sort of like using *
Can this be done?
Thanks!
Regards,
Bruce
Two Questions:
First...
+++++
I've used the Wizard to create my OLE Connection, DataAdapter's and DataSet's
to my MS Access data bases. Is there a way to change the path to the Data
Base files at Run time via Code?
.... OR should I repace the Connections with Manual Code? If so, is the
following Correct?
Dim conStr As String = _
"Provider=Microsoft.JET.OLEDB.4.0;datasource=C:\\TSdata\\ExtraServicesData.mdb"
Dim oleStr As String = "SELECT * FROM tblTimeEntry"
' Create connection object
Dim conn As OleDbConnection1 = New OleDbConnection(conStr)
' Create data adapter object
Dim da As OleDbDataAdapter = New OleDbDataAdapter(oleStr, conn)
' Create a dataset object and fill it
Dim oDataSet As New DataSet( )
da.Fill(oDataSet, "tblTimeEntry")
.... am I missing anything here? Cause I have tried it and the FILL line gets
an error
Second...
++++++++
If I've a SELECT in my DataAdapter and that has a filter like:
WHERE (User = ?)
Then I run the following.
daUserData.SelectCommand.Parameters(0).Value = UserID
daUserData.Fill(DsUserData.tblTimeEntry)
This work OK... what I'd like to know is IF there is a way to have "UserID" as
a global value instead of a filter string? In other words, I'ld like to use
the above for both filtering my data... and... selecting it all without a
filter. Sort of like using *
Can this be done?
Thanks!
Regards,
Bruce