D
Dave
Ok then... simple little exercise for me to learn ASP.NET and the simplest
things are hanging me up. Like this:
I have an .mdb that I am using the Matrix generated Select code to read
from. The SELECT function it generates works fine.
Now I am trying to Update one of the records in the little .mdb... the first
record... the following code executes without error, but nothing changes in
the .mdb either. What simple little thing am I missing?
I call it with this code, the function is below.
dim thisKey as integer = 1
dim thisSpecies as string = "a"
dim thisStage as string ="a"
UpdateAvail(thisKey, thisSpecies,thisStage)
All code below is generated by the Matrix Update tool.
Function UpdateAvail(ByVal key As Integer, ByVal species As String,
ByVal stage As String) As Integer
Dim connectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data
Source=C:\Inetpub\wwwroot\mynextbird\mynextbird.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "UPDATE [Avail] SET
[Species]=@Species, [Stage]=@Stage WHERE ([Avail].[Key] = @Key)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_key As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_key.ParameterName = "@Key"
dbParam_key.Value = key
dbParam_key.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_key)
Dim dbParam_species As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_species.ParameterName = "@Species"
dbParam_species.Value = species
dbParam_species.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_species)
Dim dbParam_stage As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_stage.ParameterName = "@Stage"
dbParam_stage.Value = stage
dbParam_stage.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_stage)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try
Return rowsAffected
End Function
things are hanging me up. Like this:
I have an .mdb that I am using the Matrix generated Select code to read
from. The SELECT function it generates works fine.
Now I am trying to Update one of the records in the little .mdb... the first
record... the following code executes without error, but nothing changes in
the .mdb either. What simple little thing am I missing?
I call it with this code, the function is below.
dim thisKey as integer = 1
dim thisSpecies as string = "a"
dim thisStage as string ="a"
UpdateAvail(thisKey, thisSpecies,thisStage)
All code below is generated by the Matrix Update tool.
Function UpdateAvail(ByVal key As Integer, ByVal species As String,
ByVal stage As String) As Integer
Dim connectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data
Source=C:\Inetpub\wwwroot\mynextbird\mynextbird.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "UPDATE [Avail] SET
[Species]=@Species, [Stage]=@Stage WHERE ([Avail].[Key] = @Key)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_key As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_key.ParameterName = "@Key"
dbParam_key.Value = key
dbParam_key.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_key)
Dim dbParam_species As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_species.ParameterName = "@Species"
dbParam_species.Value = species
dbParam_species.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_species)
Dim dbParam_stage As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_stage.ParameterName = "@Stage"
dbParam_stage.Value = stage
dbParam_stage.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_stage)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try
Return rowsAffected
End Function