473,396 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Matrix generated Access mdb Update function not working

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
Nov 17 '05 #1
1 1413
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" <d@d.com> wrote in message
news:Ts******************@twister.austin.rr.com...
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

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
4
by: Andrés Guerrero | last post by:
Hi, I'm working with Ms Access 97 and I have two tables like these: Table: Person Table: Phone Field: ID (Autonumeric) (primary key) Field: Person_ID (foering key)...
3
by: Gigi.com | last post by:
Hi All. I need some help trying to pull prices from a price matrix. Here's an example: >>>> 1000 1500 2000 2500 ----------------------------------------- 1000 ¦ 10.20 ...
3
by: Ekhaat | last post by:
Hi I followed the Web Matrix guided tour and came to the "ASP.NET Pages with Data (Microsoft Access)" part. There is really not much you can do wrong there, but for some reason, the INSERT...
4
by: Paul H | last post by:
OK, I tried getting and old Newbury Data ND2500 working using the "Generic /Text only" driver in Win XP. It prints, but I could not find a way to set a custom page size that matches the paper I am...
5
by: adam.kleinbaum | last post by:
Hi there, I'm a novice C programmer working with a series of large (30,000 x 30,000) sparse matrices on a Linux system using the GCC compiler. To represent and store these matrices, I'd like to...
10
by: Bernhard Reinhardt | last post by:
Hi, I read data from a file into a 4 dimensional array. The data has a size of 5MB (could later be up to 500MB). I want to pass the matrix to subroutines. What is the cleverst (and for a...
6
by: lovecreatesbea... | last post by:
Hello experts, I code an function to rotate a matrix by 90 degrees clockwise. The matrix can be in any size provided its length equals to width. The one minor limitation is that this requires an...
10
by: Babak | last post by:
Hi, I've developed a C program which contains a large number of vectors and matrices operations. Throughout my code, I used the template from the Numerical Recipes book to define vectors and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.