Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Matrix generated Access mdb Update function not working

Reply
Thread Tools

Matrix generated Access mdb Update function not working

 
 
Dave
Guest
Posts: n/a
 
      09-01-2003
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.md b"
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


 
Reply With Quote
 
 
 
 
Anthony Williams
Guest
Posts: n/a
 
      09-10-2003
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

"Dave" <> wrote in message
news:Tsz4b.20060$...
> 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.md b"
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MDB Database won't update Jonathan Upright ASP .Net 4 10-06-2005 01:07 AM
MDB to MDB Event Notification John Schult Java 0 05-04-2005 01:26 AM
Faster access to MDB? MS Access MDB and ASP =?Utf-8?B?UGhpbA==?= ASP .Net 8 01-27-2005 07:08 PM
Could not display a column in Access 2000 nwind.mdb in a listbox using ole DataAdapter, Connection and dataset controls yma ASP .Net 1 12-16-2003 06:20 PM
Matrix generated Access mdb Update function not working Dave ASP .Net 1 09-10-2003 07:55 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57