Matrix generated Access mdb Update function not working

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
 
A

Anthony Williams

If nothing is happening to the MDB then it's likely an error's being thrown
in the Try...End Try statement.

However, because you're not catching any exceptions, what you're doing is
just ignoring any errors that are thrown. Try commenting out the Try...End
Try statements and see what happens - it's probable that you'll encounter an
error, and when you do, it'll give you a little more information on where to
start looking.

Do that and if you can't fix it, post a reply here.

Cheers,
Anth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top