Asp.Netram zy12yAsked Mar 15, 2014, 12:51 AM EDT8 answersShareLinkedInXCopy linkSaveI suppose to create a web form which insert data into db on button clicks ... but unfotunately it is not inseting to database
Asp.Netram zy12yAsked Mar 15, 2014, 12:51 AM EDT8 answersShareLinkedInXCopy linkSaveI suppose to create a web form which insert data into db on button clicks ... but unfotunately it is not inseting to database
Shweta LodhaRank #31 · 39.8K reputation12y agoPosted Mar 15, 2014, 12:52 AM EDT0what error are you getting ?Can you paste your code here ?0
ram zy75 reputation12y agoPosted Mar 15, 2014, 1:05 AM EDT0i have uploaded my codeactually its not shwoing any error0
Biswa Pujarini MohapatraRank #465 · 5.4K reputation12y agoPosted Mar 15, 2014, 2:22 AM EDT0i see your insert code is in page_load event. please move it to Submit_button click event - 1. go to projectadd.aspx -->double click on the submit button -->then in projectadd.aspx.cs page protected void Submit_Button_Click(object sender, EventArgs e) { int userId = 0; string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand("Employee")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", N_TB.Text.Trim()); cmd.Parameters.AddWithValue("@Description", D_TB.Text.Trim()); cmd.Parameters.AddWithValue("@Subject", S_TB.Text.Trim()); cmd.Parameters.AddWithValue("@Topic", TP_TB.Text.Trim()); cmd.Parameters.AddWithValue("@TotalPages", TotalPages_TB.Text.Trim()); cmd.Parameters.AddWithValue("@CostPerPage", CostPerPage_TB.Text.Trim()); cmd.Parameters.AddWithValue("@TotalCost", TotalCost_TB.Text.Trim()); cmd.Parameters.AddWithValue("@StartDate", StartDate_TB.Text.Trim()); cmd.Parameters.AddWithValue("@Deadline", Deadline_TB.Text.Trim()); cmd.Parameters.AddWithValue("@Reference", Reference_TB.Text.Trim()); cmd.Parameters.AddWithValue("@ProjectStyleId", ProjectStyleId_TB.Text.Trim()); cmd.Parameters.AddWithValue("@CustomerId", CustomerId_TB.Text.Trim()); cmd.Parameters.AddWithValue("@IsActive", IsActive_TB.Text.Trim()); cmd.Parameters.AddWithValue("@CreatedOn", CreatedBy_TB.Text.Trim()); cmd.Parameters.AddWithValue("CreatedBy", CreatedBy_TB.Text.Trim()); cmd.Parameters.AddWithValue("UpdatedOn", UpdatedOn_TB.Text.Trim()); cmd.Parameters.AddWithValue("UpdatedBy", UpdatedBy_TB.Text.Trim()); cmd.Connection = con; con.Open(); userId = Convert.ToInt32(cmd.ExecuteScalar()); con.Close(); } } }also i didnot find any connectionstring in web.configplease add your databse connection string in web.config with key name as "constr"0
ram zy75 reputation12y agoPosted Mar 15, 2014, 9:27 AM EDT0this the connection string ... but not working 0
Biswa Pujarini MohapatraRank #465 · 5.4K reputation12y agoPosted Mar 15, 2014, 6:36 PM EDT0can you paste your connection string here if possible and put your code in try catch0
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputation12y agoPosted Mar 16, 2014, 2:08 AM EDT0Hi, We are not able to see the connection string.Please post it again.0
ram zy75 reputation12y agoPosted Mar 16, 2014, 2:14 AM EDT0 connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\celebral.mdf;User Instance=true" providerName="System.Data.SqlClient" /> 0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Shweta LodhaRank #31 · 39.8K reputationPosted Mar 15, 2014, 12:52 AM EDT
Can you paste your code here ?
ram zy75 reputationPosted Mar 15, 2014, 1:05 AM EDT
Biswa Pujarini MohapatraRank #465 · 5.4K reputationPosted Mar 15, 2014, 2:22 AM EDT
1. go to projectadd.aspx -->double click on the submit button -->
then in projectadd.aspx.cs page
also i didnot find any connectionstring in web.config
please add your databse connection string in web.config with key name as "constr"
ram zy75 reputationPosted Mar 15, 2014, 9:27 AM EDT
Biswa Pujarini MohapatraRank #465 · 5.4K reputationPosted Mar 15, 2014, 6:36 PM EDT
ram zy75 reputationPosted Mar 16, 2014, 2:06 AM EDT
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Mar 16, 2014, 2:08 AM EDT
ram zy75 reputationPosted Mar 16, 2014, 2:14 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts