Talk to Webmaster Tony John
|
Forums » .NET » ASP.NET »
Posted Date: 21 Sep 2008 Posted By:: shashi booshan Member Level: Bronze Member Rank: 2513 Points: 1
Responses:
4
|
Hi guys i want to insert data into the database through my asp.net form... i want to insert data into 2 tables for that i hv made a stored pprocedure consisting of 2 tables... i also want to insert some null values.. for that i hv declared the specified fields to null in my stored procedure.
when i click the data no error or exception comes bt at the same time insertion is also not taking place and over the page i get a string saying "Procedure or function insert_Data has too many arguments specified. " i want to check whether the rows have been updated or not..
pls somebody help guys.
this is my code....
**********************************************************************************
protected void button1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=Project_Airways;User Id=sa;Password=sql2005"); SqlCommand cmd = new SqlCommand("insert_Data ", conn); cmd.CommandType = CommandType.StoredProcedure;
try { cmd.Parameters.AddWithValue("@Origin_Place", ddl1.SelectedItem.Text); cmd.Parameters.AddWithValue("@Dest_Place", ddl4.SelectedItem.Text); cmd.Parameters.AddWithValue("@Onw_Date", txtorgdate.Text); cmd.Parameters.AddWithValue("@Ret_Date", txtdestdate.Text); cmd.Parameters.AddWithValue("@No_of_Adults", ddl2.SelectedItem.Text); cmd.Parameters.AddWithValue("@No_of_Children", ddl3.SelectedItem.Text); cmd.Parameters.AddWithValue("@No_of_Infants", ddl5.SelectedItem.Text); cmd.Parameters.AddWithValue("@mp_name", txt1.Text); cmd.Parameters.AddWithValue("@mp_age", Convert.ToInt32(txt7.Text)); cmd.Parameters.AddWithValue("@mp_gendr", ddl7.SelectedItem.Text); cmd.Parameters.AddWithValue("@p1_name", txt2.Text); cmd.Parameters.AddWithValue("@p1_age", txt8.Text); cmd.Parameters.AddWithValue("@p1_gendr", ddl8.SelectedItem.Text); cmd.Parameters.AddWithValue("@p2_name", txt3.Text); cmd.Parameters.AddWithValue("@p2_age", txt9.Text); cmd.Parameters.AddWithValue("@p2_gendr", ddl9.SelectedItem.Text); cmd.Parameters.AddWithValue("@p3_name", txt4.Text); cmd.Parameters.AddWithValue("@p3_age", txt10.Text); cmd.Parameters.AddWithValue("@p3_gendr", ddl10.SelectedItem.Text); cmd.Parameters.AddWithValue("@mp_trav_doc", ddl13.SelectedItem.Text); cmd.Parameters.AddWithValue("@trav_doc_no", txt15.Text); cmd.Parameters.AddWithValue("@expiry_date", txt13.Text); cmd.Parameters.AddWithValue("@issue_country", ddl14.SelectedItem.Text); cmd.Parameters.AddWithValue("@nationality", txt14.Text); SqlParameter pr = new SqlParameter(); cmd.Parameters.Add(pr); conn.Open(); cmd.ExecuteNonQuery(); Response.Redirect("pay.aspx"); } catch (SqlException se) { Response.Write(se.Message); } finally { conn.Close(); } } ********************************************************************************
thanks in adv
regards shashi
|
Responses
|
#297979 Author: SK Member Level: Bronze Member Rank: 0 Date: 21/Sep/2008 Rating:  Points: 0 | check u r database attributes
| #297981 Author: shashi booshan Member Level: Bronze Member Rank: 2513 Date: 21/Sep/2008 Rating:  Points: 1 | i hv checked.. bt still its giving me proble...
pls guys help me..
| #298058 Author: Miss Meetu Choudhary Member Level: Gold Member Rank: 14 Date: 22/Sep/2008 Rating:  Points: 5 | Hi Shahi I would like to see The code of your Stored Procedure also may be the problem is the no of arguments you are taking in the stored procedure doesnot match the no of argments ur passing through your form... or if they are same then may be there type is mismatching i would like to ask you to post the query or the cursor what ever you have made in your sp.....
-- I Would Love To Change The World But They Wont Give Me The Source Code
Spread D Smile n Never Say Bye
May Lord Shiva Bless All of US Thanks and Regards Meetu Choudhary ~~MEET~~
Thanks and Regards Miss Meetu Choudhary (Site Coordinator) Go Green Save Green My Profile on Google
| #298225 Author: Sathish Kumar Member Level: Gold Member Rank: 0 Date: 22/Sep/2008 Rating:  Points: 1 | Check ur Stored Procedure parameter and sqlcommand Paramenter are matches.
|
|
| Post Reply |
|
|
|
 | | This thread is locked for new responses. Please post your comments and questions as a separate thread. If required, refer to the URL of this page in your new post. |
|
|
|
|
|
Active MembersTodayLast 7 Daysmore...
|