R
Rick Lederman
I've been developing in VB6 & DAO for quite some time. I have figured out
how to use ADO (see the following code sample) but want to drop ADO and move
to ADO.NET. Can someone please point me to an article or book or re-do the
code below so I can move on. I have the MSDN article "ADO.NET and You"
which got me started, I have a good connection string but just can't figure
out how to get a single record, grab it's value, and update it if necessary.
Thanks!
Rick Lederman, (e-mail address removed), www.soaringsoftware.com
Dim cnFAMax As New ADODB.Connection
cnFAMax.Provider = "Microsoft.Jet.OLEDB.4.0;"
cnFAMax.CursorLocation = ADODB.CursorLocationEnum.adUseServer
cnFAMax.Open("Data Source=" & sCDatabaseName & "; Jet OLEDBatabase
Password=" & sMasterDatabasePassword & ";")
sSql.Remove(0, sSql.Length)
sSql.Append("SELECT PARAMETERS_.* FROM PARAMETERS_;")
Try
rsSearch.Open(sSql.ToString, cnFAMax,
ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
Catch ex As Exception
MsgBox("The Recordset failed to open")
End Try
'MyOptions.PercentRemainingRed()
rsSearch.Find(("NAME_ = 'MyOptions.PercentRemainingRed'"))
If rsSearch.EOF = True Then
MyOptions.PercentRemainingRed = 30
rsSearch.AddNew()
rsSearch.Fields("NAME_").Value = "MyOptions.PercentRemainingRed"
rsSearch.Fields("VALUE_DOUBLE").Value = 30
rsSearch.Update()
Else
MyOptions.PercentRemainingRed = rsSearch.Fields("VALUE_DOUBLE").Value
End If
rsSearch.MoveFirst()
' Then I do another .Find to find the next appropriate record & test it's
value the same.
Thanks again!
how to use ADO (see the following code sample) but want to drop ADO and move
to ADO.NET. Can someone please point me to an article or book or re-do the
code below so I can move on. I have the MSDN article "ADO.NET and You"
which got me started, I have a good connection string but just can't figure
out how to get a single record, grab it's value, and update it if necessary.
Thanks!
Rick Lederman, (e-mail address removed), www.soaringsoftware.com
Dim cnFAMax As New ADODB.Connection
cnFAMax.Provider = "Microsoft.Jet.OLEDB.4.0;"
cnFAMax.CursorLocation = ADODB.CursorLocationEnum.adUseServer
cnFAMax.Open("Data Source=" & sCDatabaseName & "; Jet OLEDBatabase
Password=" & sMasterDatabasePassword & ";")
sSql.Remove(0, sSql.Length)
sSql.Append("SELECT PARAMETERS_.* FROM PARAMETERS_;")
Try
rsSearch.Open(sSql.ToString, cnFAMax,
ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
Catch ex As Exception
MsgBox("The Recordset failed to open")
End Try
'MyOptions.PercentRemainingRed()
rsSearch.Find(("NAME_ = 'MyOptions.PercentRemainingRed'"))
If rsSearch.EOF = True Then
MyOptions.PercentRemainingRed = 30
rsSearch.AddNew()
rsSearch.Fields("NAME_").Value = "MyOptions.PercentRemainingRed"
rsSearch.Fields("VALUE_DOUBLE").Value = 30
rsSearch.Update()
Else
MyOptions.PercentRemainingRed = rsSearch.Fields("VALUE_DOUBLE").Value
End If
rsSearch.MoveFirst()
' Then I do another .Find to find the next appropriate record & test it's
value the same.
Thanks again!