update command in webmatrix

M

Mark

I'm having a problem updating an access db using the update code wizard in
webmatrix. I want to update all the data n a particular record.
The record I need to update uses a primary key of 'AdID'. I want to update
this record when AdID = a particular number (determined by user action) I
can update records when I use a field other than the primary key feld to
select the record.

Here is the code (and I've verified that the function is getting called, but
no errors are shown and the data is not updated, as if the primary key is
not being found, and I know it's there because it's actully read from a
querystring.)Sorry, heres the code:
'**********************************************
Function updateAd_NoPic(ByVal adID As Integer, ByVal adTitle As String,
ByVal phoneNumber As String, ByVal askingPrice As Double, ByVal adEmail As
String, ByVal showEmail As String, ByVal adText As String) As Integer
Dim connectionString As String =
ConfigurationSettings.AppSettings( "constring" )
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "UPDATE [Ads] SET [AdTitle]=@AdTitle,
[PhoneNumber]=@PhoneNumber, [AskingPrice]=@A"& _
"skingPrice, [AdEmail]=@AdEmail, [ShowEmail]=@ShowEmail, [AdText]=@AdText
WHERE ("& _
"[Ads].[AdID] = @AdID)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_adID As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_adID.ParameterName = "@AdID"
dbParam_adID.Value = adID
dbParam_adID.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_adID)
Dim dbParam_adTitle As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_adTitle.ParameterName = "@AdTitle"
dbParam_adTitle.Value = adTitle
dbParam_adTitle.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_adTitle)
Dim dbParam_phoneNumber As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_phoneNumber.ParameterName = "@PhoneNumber"
dbParam_phoneNumber.Value = phoneNumber
dbParam_phoneNumber.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_phoneNumber)
Dim dbParam_askingPrice As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_askingPrice.ParameterName = "@AskingPrice"
dbParam_askingPrice.Value = askingPrice
dbParam_askingPrice.DbType = System.Data.DbType.Double
dbCommand.Parameters.Add(dbParam_askingPrice)
Dim dbParam_adEmail As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_adEmail.ParameterName = "@AdEmail"
dbParam_adEmail.Value = adEmail
dbParam_adEmail.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_adEmail)
Dim dbParam_showEmail As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_showEmail.ParameterName = "@ShowEmail"
dbParam_showEmail.Value = showEmail
dbParam_showEmail.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_showEmail)
Dim dbParam_adText As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_adText.ParameterName = "@AdText"
dbParam_adText.Value = adText
dbParam_adText.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_adText)

Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try

Return rowsAffected
End Function


'******************************************

I've tried everything I can think of.....

Thanks,

Mark
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top