mahmud_uk

mahmud_uk

  • NA
  • 48
  • 0

Problem with Insertion to Access DB - 6 BADBINDINFO.

Jan 8 2006 6:15 PM
Hi Guys i have this script, when i execute this script i get this error:
System.InvalidOperationException: System.Data.OleDb.OleDbDataAdapter internal error: invalid parameter accessor: 6 BADBINDINFO.

I do not have a clue what thsi error means, all states that theres something wrong with myCmd.ExecuteNonQuery ( );
Will apprechiate anyone help.
Thanks, Mac

public void addMessage ( object src, EventArgs e ) {

if ( Page.IsValid ) {

OleDbCommand myCmd = new OleDbCommand ( );

myCmd.Connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + Server.MapPath("aspa_oledb.mdb"));

// define insert command parameters

myCmd.CommandText = "INSERT INTO aspx_messages ( MessageDate, MessageFrom, Email, MessageSubject, MessageBody ) VALUES ( ?, ?, ?, ?, ? ) SET ? = @@Identity";

myCmd.Parameters.Add ( "Date", OleDbType.Date ).Value = DateTime.Now;

myCmd.Parameters.Add ( "From", OleDbType.Char ).Value = msgFrom.Value;

myCmd.Parameters.Add ( "Mail", OleDbType.Char ).Value = msgEmail.Value;

myCmd.Parameters.Add ( "Subject", OleDbType.Char ).Value = msgSubject.Value;

myCmd.Parameters.Add ( "Body", OleDbType.VarChar ).Value = msgBody.Value;

// used for getting new record ID

myCmd.Parameters.Add ( "Id", OleDbType.SmallInt );

myCmd.Parameters [ "Id" ].Direction = ParameterDirection.Output;

myCmd.Connection.Open ( );

// do insert

myCmd.ExecuteNonQuery ( );

// fetch new record into reader

myCmd.CommandText = "SELECT * FROM aspx_messages WHERE MessageId=" +

myCmd.Parameters [ "Id" ].Value;

postDetails.DataSource = myCmd.ExecuteReader ( CommandBehavior.SingleRow );

postDetails.DataBind ( );

myCmd.Connection.Close ( );

}

}


Answers (1)