update command in webmatrix

Discussion in 'ASP .Net' started by Mark, Nov 8, 2003.

  1. Mark

    Mark Guest

    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
    Mark, Nov 8, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ccd

    Webmatrix stuck

    ccd, Aug 21, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    368
  2. umberto

    [WebMatrix] Problem with MSDE

    umberto, Nov 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    357
    umberto
    Nov 8, 2003
  3. umberto
    Replies:
    0
    Views:
    392
    umberto
    Nov 18, 2003
  4. Replies:
    0
    Views:
    309
  5. =?Utf-8?B?RGF2aWQ=?=

    Webmatrix: Wizard's UPDATE code does nothing?

    =?Utf-8?B?RGF2aWQ=?=, Sep 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    388
    =?Utf-8?B?RGF2aWQ=?=
    Sep 15, 2004
Loading...

Share This Page