Need help with ADO.Net with Access 2000 mdb

Results 1 to 2 of 2

Thread: Need help with ADO.Net with Access 2000 mdb

  1. #1
    Join Date
    Dec 1969

    Default Need help with ADO.Net with Access 2000 mdb

    I&#039;m trying to use an Access query with parameters to update a table. The problem is that there&#039;s no update to the table and there&#039;s also no error either.<BR><BR>Here&#039;s the code I&#039;ve got so far.<BR>This is the access query:<BR>UPDATE ForSaleItem SET <BR>ForSaleItem.ForSaleItemDescription = [ItemDescription],<BR>ForSaleItem.ForSaleItemHeader = [ItemHeader], <BR>ForSaleItem.ForSaleItemPrice = [ItemPrice], <BR>ForSaleItem.ForSaleItemActive = [ItemActive], <BR>ForSaleItem.ForSaleItemImageName = [ItemImageName]<BR>WHERE (((ForSaleItem.ForSaleItemID)=[ItemID]));<BR><BR><BR>Here&#039;s my update sub routine:<BR><BR>Public Sub ForSaleItemUpd()<BR> Dim cmd As OleDb.OleDbCommand<BR> Try<BR> cmd = New OleDb.OleDbCommand("ForSaleItemUpd", Util.OpenConn)<BR> cmd.CommandType = CommandType.StoredProcedure<BR> cmd.Parameters.Add("@ItemID", OleDb.OleDbType.Integer).Value = Me.itemIDText.Text.Trim<BR> cmd.Parameters.Add("@ItemDescription", OleDb.OleDbType.VarChar, 255).Value = Me.descriptionText.Text.Trim<BR> cmd.Parameters.Add("@ItemHeader", OleDb.OleDbType.VarChar, 60).Value = Me.headerText.Text.Trim<BR> cmd.Parameters.Add("@ItemPrice", OleDb.OleDbType.Currency, 50).Value = Me.priceText.Text.Trim<BR> cmd.Parameters.Add("@ItemActive", OleDb.OleDbType.Boolean).Value = True<BR> cmd.Parameters.Add("@ItemImageName", OleDb.OleDbType.VarChar, 60).Value = Me.imageText.Text.Trim<BR><BR> cmd.ExecuteNonQuery()<BR><BR> Catch exc As Exception<BR> ErrHandler(exc)<BR> Finally<BR> cmd.Dispose()<BR> cmd = Nothing<BR> End Try<BR>End Sub<BR><BR>Here&#039;s my open connection function<BR>Public Shared Function OpenConn() As OleDbConnection<BR> &#039; +-------------------------------------------+<BR> &#039; &#124 Variable declarations (do not initialize) &#124<BR> &#039; +-------------------------------------------+<BR> Dim conn As OleDbConnection<BR> Try<BR> &#039;Open a connection<BR> conn = New OleDbConnection(AppSettings("ConnectionString"))<B R> conn.Open()<BR> Return conn<BR> Catch exc As Exception<BR> HandleException(exc)<BR> End Try<BR>End Function<BR><BR><BR>Anybody got any suggestions?<BR>I&#039;ve tried doing a Response.Write(cmd.ExecuteNonQuery() & " rows affected<BR>") in my page and it obviously prints "0 rows affected" right now.<BR><BR>matt<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Need help with ADO.Net with Access 2000 mdb

    use the "@" in your query<BR><BR>UPDATE ForSaleItem SET <BR>ForSaleItem.ForSaleItemDescription = [@ItemDescription], <BR>ForSaleItem.ForSaleItemHeader = [@ItemHeader], <BR>ForSaleItem.ForSaleItemPrice = [@ItemPrice], <BR>ForSaleItem.ForSaleItemActive = [@ItemActive], <BR>ForSaleItem.ForSaleItemImageName = [@ItemImageName] <BR>WHERE (((ForSaleItem.ForSaleItemID)=[@ItemID]));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts