944,196 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 7666
  • ASP.NET RSS
Apr 25th, 2005
0

help connecting a form to a database.. error message

Expand Post »
sending form data to database creates a error!
hi i have created a form which should connect to a database and update it when the user inputs into the form, however as soon as i hit the button on the form i get the error No value given for one or more required parameters., I have checked the table names are all correct and cant figure out why it does this can anyone help??



void Page_Load()
{

if(IsPostBack)
{
//Build connection object //
OleDbConnection conn = new OleDbConnection() ;
string connStr;
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;";
connStr += "Data Source= " + Server.MapPath("test.mdb");
conn.ConnectionString = connStr;

// Build command object //

string queryString;
queryString = "Insert INTO Customer(C_FirstName, C_LastName) VALUES(";
queryString += fn.Text + "," + "'" + sn.Text + "')";

OleDbCommand dbCommand = new OleDbCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = conn;

// Open the connection //
conn.Open();


// insert new record using method executeNonQry
dbCommand.ExecuteNonQuery();


} // end of if


} // end of page_load

the error i recieve is as follows:




No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

Source Error:

Line 32:
Line 33: // insert new record using method executeNonQry
Line 34: dbCommand.ExecuteNonQuery();
Line 35:
Line 36:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
needhelp2005 is offline Offline
1 posts
since Apr 2005
May 30th, 2005
0

Re: help connecting a form to a database.. error message

Hmmm, well I used your code and it worked for me?

Have you put break points in and seen what values are being passed?


Quote originally posted by needhelp2005 ...
sending form data to database creates a error!
hi i have created a form which should connect to a database and update it when the user inputs into the form, however as soon as i hit the button on the form i get the error No value given for one or more required parameters., I have checked the table names are all correct and cant figure out why it does this can anyone help??



void Page_Load()
{

if(IsPostBack)
{
//Build connection object //
OleDbConnection conn = new OleDbConnection() ;
string connStr;
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;";
connStr += "Data Source= " + Server.MapPath("test.mdb");
conn.ConnectionString = connStr;

// Build command object //

string queryString;
queryString = "Insert INTO Customer(C_FirstName, C_LastName) VALUES(";
queryString += fn.Text + "," + "'" + sn.Text + "')";

OleDbCommand dbCommand = new OleDbCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = conn;

// Open the connection //
conn.Open();


// insert new record using method executeNonQry
dbCommand.ExecuteNonQuery();


} // end of if


} // end of page_load

the error i recieve is as follows:




No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

Source Error:

Line 32:
Line 33: // insert new record using method executeNonQry
Line 34: dbCommand.ExecuteNonQuery();
Line 35:
Line 36:
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Server Error message when opening asp.net applicationm
Next Thread in ASP.NET Forum Timeline: requiredfieldvalidator problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC