Saving Data entered in gridview using c# and sqlserver
I have a form that has a asp.net gridview contained in it, on page load, I disabled some textboxes of the grid using jQuery.
my save method to the database is not working properly. I removed the grid from the "save" method and it works with the 2 textboxes.
protected void saverecords() {
try {
int suc = 0;
conn = new SqlConnection(connString);
conn.Open();
sqltrans = conn.BeginTransaction();
string sqldelete = "delete from TrainEmpha where TrainCode = '" + txtcode.Text.ToString().Trim() + "'";
SqlCommand comm = new SqlCommand(sqldelete, conn, sqltrans);
comm.ExecuteNonQuery();
comm.Dispose();
string insertgroup = " Insert into TrainEmpha (TrainCode, TrainDesc,disreglev,EmphaLevel,Award1,Award2,Award3,Award4)" +
" Values (@TrainCode, @TrainDesc,@disreglev,@EmphaLevel,@Award1,@Award2,@Award3,@Award4)";
foreach(GridViewRow gvr in gridview.Rows) {
string drplevel = ((DropDownList) gvr.FindControl("drp_grid_lvl")).Text.Trim();
string txttrain = ((TextBox) gvr.FindControl("txttrained")).Text.Trim();
string txtaward_1 = ((TextBox) gvr.FindControl("txtaward1")).Text.Trim();
string txtaward_2 = ((TextBox) gvr.FindControl("txtaward2")).Text.Trim();
string txtaward_3 = ((TextBox) gvr.FindControl("txtaward3")).Text.Trim();
string txtaward_4 = ((TextBox) gvr.FindControl("txtaward4")).Text.Trim();
comm = new SqlCommand(insertgroup, conn, sqltrans);
comm.Parameters.Add("@TrainCode", SqlDbType.VarChar);
comm.Parameters["@TrainCode"].Value = txtcode.Text.Trim();
comm.Parameters.Add("@TrainDesc", SqlDbType.VarChar);
comm.Parameters["@TrainDesc"].Value = txtdescrip.Text.Trim();
comm.Parameters.Add("@disreglev", SqlDbType.VarChar);
comm.Parameters["@disreglev"].Value = drplevel.Trim();
comm.Parameters.Add("@EmphaLevel", SqlDbType.VarChar);
comm.Parameters["@EmphaLevel"].Value = txttrain.Trim();
comm.Parameters.Add("@Award1", SqlDbType.VarChar);
comm.Parameters["@Award1"].Value = txtaward_1.Trim();
comm.Parameters.Add("@Award2", SqlDbType.VarChar);
comm.Parameters["@Award2"].Value = txtaward_2.Trim();
comm.Parameters.Add("@Award3", SqlDbType.VarChar);
comm.Parameters["@Award3"].Value = txtaward_3.Trim();
comm.Parameters.Add("@Award4", SqlDbType.VarChar);
comm.Parameters["@Award4"].Value = txtaward_4.Trim();
suc += comm.ExecuteNonQuery();
comm.Dispose();
}
if (suc > 0) {
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert(' RECORDS SAVED SUCCESSFULLY!');", true);
sqltrans.Commit();
} else {
lblDisplayErr.Text = "COULD NOT SAVE";
}
c# asp.net sql-server gridview
|
show 1 more comment
I have a form that has a asp.net gridview contained in it, on page load, I disabled some textboxes of the grid using jQuery.
my save method to the database is not working properly. I removed the grid from the "save" method and it works with the 2 textboxes.
protected void saverecords() {
try {
int suc = 0;
conn = new SqlConnection(connString);
conn.Open();
sqltrans = conn.BeginTransaction();
string sqldelete = "delete from TrainEmpha where TrainCode = '" + txtcode.Text.ToString().Trim() + "'";
SqlCommand comm = new SqlCommand(sqldelete, conn, sqltrans);
comm.ExecuteNonQuery();
comm.Dispose();
string insertgroup = " Insert into TrainEmpha (TrainCode, TrainDesc,disreglev,EmphaLevel,Award1,Award2,Award3,Award4)" +
" Values (@TrainCode, @TrainDesc,@disreglev,@EmphaLevel,@Award1,@Award2,@Award3,@Award4)";
foreach(GridViewRow gvr in gridview.Rows) {
string drplevel = ((DropDownList) gvr.FindControl("drp_grid_lvl")).Text.Trim();
string txttrain = ((TextBox) gvr.FindControl("txttrained")).Text.Trim();
string txtaward_1 = ((TextBox) gvr.FindControl("txtaward1")).Text.Trim();
string txtaward_2 = ((TextBox) gvr.FindControl("txtaward2")).Text.Trim();
string txtaward_3 = ((TextBox) gvr.FindControl("txtaward3")).Text.Trim();
string txtaward_4 = ((TextBox) gvr.FindControl("txtaward4")).Text.Trim();
comm = new SqlCommand(insertgroup, conn, sqltrans);
comm.Parameters.Add("@TrainCode", SqlDbType.VarChar);
comm.Parameters["@TrainCode"].Value = txtcode.Text.Trim();
comm.Parameters.Add("@TrainDesc", SqlDbType.VarChar);
comm.Parameters["@TrainDesc"].Value = txtdescrip.Text.Trim();
comm.Parameters.Add("@disreglev", SqlDbType.VarChar);
comm.Parameters["@disreglev"].Value = drplevel.Trim();
comm.Parameters.Add("@EmphaLevel", SqlDbType.VarChar);
comm.Parameters["@EmphaLevel"].Value = txttrain.Trim();
comm.Parameters.Add("@Award1", SqlDbType.VarChar);
comm.Parameters["@Award1"].Value = txtaward_1.Trim();
comm.Parameters.Add("@Award2", SqlDbType.VarChar);
comm.Parameters["@Award2"].Value = txtaward_2.Trim();
comm.Parameters.Add("@Award3", SqlDbType.VarChar);
comm.Parameters["@Award3"].Value = txtaward_3.Trim();
comm.Parameters.Add("@Award4", SqlDbType.VarChar);
comm.Parameters["@Award4"].Value = txtaward_4.Trim();
suc += comm.ExecuteNonQuery();
comm.Dispose();
}
if (suc > 0) {
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert(' RECORDS SAVED SUCCESSFULLY!');", true);
sqltrans.Commit();
} else {
lblDisplayErr.Text = "COULD NOT SAVE";
}
c# asp.net sql-server gridview
Are you actually receiving an exception on the call to comm.ExecuteNonQuery(), or are you receiving "COULD NOT SAVE" in your label?
– Allumearz
Nov 15 '18 at 9:01
I receive no message at all
– Victor Ikpeni
Nov 15 '18 at 9:38
If your method is actually getting called, if you are not getting any exceptions, then according to the code you posted, it should always run through the final test of (suc > 0) - therefore you should at least get "COULD NOT SAVE" in lblDisplayErr.Text - have you debugged the application and stepped through the code?
– Allumearz
Nov 15 '18 at 9:45
Ah - I just noticed that the code you posted is partial, and is inside an outer try block. You therefore must be receiving an exception which is jumping out of the try block.
– Allumearz
Nov 15 '18 at 9:48
Can you update your post with the full method code?
– Allumearz
Nov 15 '18 at 9:49
|
show 1 more comment
I have a form that has a asp.net gridview contained in it, on page load, I disabled some textboxes of the grid using jQuery.
my save method to the database is not working properly. I removed the grid from the "save" method and it works with the 2 textboxes.
protected void saverecords() {
try {
int suc = 0;
conn = new SqlConnection(connString);
conn.Open();
sqltrans = conn.BeginTransaction();
string sqldelete = "delete from TrainEmpha where TrainCode = '" + txtcode.Text.ToString().Trim() + "'";
SqlCommand comm = new SqlCommand(sqldelete, conn, sqltrans);
comm.ExecuteNonQuery();
comm.Dispose();
string insertgroup = " Insert into TrainEmpha (TrainCode, TrainDesc,disreglev,EmphaLevel,Award1,Award2,Award3,Award4)" +
" Values (@TrainCode, @TrainDesc,@disreglev,@EmphaLevel,@Award1,@Award2,@Award3,@Award4)";
foreach(GridViewRow gvr in gridview.Rows) {
string drplevel = ((DropDownList) gvr.FindControl("drp_grid_lvl")).Text.Trim();
string txttrain = ((TextBox) gvr.FindControl("txttrained")).Text.Trim();
string txtaward_1 = ((TextBox) gvr.FindControl("txtaward1")).Text.Trim();
string txtaward_2 = ((TextBox) gvr.FindControl("txtaward2")).Text.Trim();
string txtaward_3 = ((TextBox) gvr.FindControl("txtaward3")).Text.Trim();
string txtaward_4 = ((TextBox) gvr.FindControl("txtaward4")).Text.Trim();
comm = new SqlCommand(insertgroup, conn, sqltrans);
comm.Parameters.Add("@TrainCode", SqlDbType.VarChar);
comm.Parameters["@TrainCode"].Value = txtcode.Text.Trim();
comm.Parameters.Add("@TrainDesc", SqlDbType.VarChar);
comm.Parameters["@TrainDesc"].Value = txtdescrip.Text.Trim();
comm.Parameters.Add("@disreglev", SqlDbType.VarChar);
comm.Parameters["@disreglev"].Value = drplevel.Trim();
comm.Parameters.Add("@EmphaLevel", SqlDbType.VarChar);
comm.Parameters["@EmphaLevel"].Value = txttrain.Trim();
comm.Parameters.Add("@Award1", SqlDbType.VarChar);
comm.Parameters["@Award1"].Value = txtaward_1.Trim();
comm.Parameters.Add("@Award2", SqlDbType.VarChar);
comm.Parameters["@Award2"].Value = txtaward_2.Trim();
comm.Parameters.Add("@Award3", SqlDbType.VarChar);
comm.Parameters["@Award3"].Value = txtaward_3.Trim();
comm.Parameters.Add("@Award4", SqlDbType.VarChar);
comm.Parameters["@Award4"].Value = txtaward_4.Trim();
suc += comm.ExecuteNonQuery();
comm.Dispose();
}
if (suc > 0) {
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert(' RECORDS SAVED SUCCESSFULLY!');", true);
sqltrans.Commit();
} else {
lblDisplayErr.Text = "COULD NOT SAVE";
}
c# asp.net sql-server gridview
I have a form that has a asp.net gridview contained in it, on page load, I disabled some textboxes of the grid using jQuery.
my save method to the database is not working properly. I removed the grid from the "save" method and it works with the 2 textboxes.
protected void saverecords() {
try {
int suc = 0;
conn = new SqlConnection(connString);
conn.Open();
sqltrans = conn.BeginTransaction();
string sqldelete = "delete from TrainEmpha where TrainCode = '" + txtcode.Text.ToString().Trim() + "'";
SqlCommand comm = new SqlCommand(sqldelete, conn, sqltrans);
comm.ExecuteNonQuery();
comm.Dispose();
string insertgroup = " Insert into TrainEmpha (TrainCode, TrainDesc,disreglev,EmphaLevel,Award1,Award2,Award3,Award4)" +
" Values (@TrainCode, @TrainDesc,@disreglev,@EmphaLevel,@Award1,@Award2,@Award3,@Award4)";
foreach(GridViewRow gvr in gridview.Rows) {
string drplevel = ((DropDownList) gvr.FindControl("drp_grid_lvl")).Text.Trim();
string txttrain = ((TextBox) gvr.FindControl("txttrained")).Text.Trim();
string txtaward_1 = ((TextBox) gvr.FindControl("txtaward1")).Text.Trim();
string txtaward_2 = ((TextBox) gvr.FindControl("txtaward2")).Text.Trim();
string txtaward_3 = ((TextBox) gvr.FindControl("txtaward3")).Text.Trim();
string txtaward_4 = ((TextBox) gvr.FindControl("txtaward4")).Text.Trim();
comm = new SqlCommand(insertgroup, conn, sqltrans);
comm.Parameters.Add("@TrainCode", SqlDbType.VarChar);
comm.Parameters["@TrainCode"].Value = txtcode.Text.Trim();
comm.Parameters.Add("@TrainDesc", SqlDbType.VarChar);
comm.Parameters["@TrainDesc"].Value = txtdescrip.Text.Trim();
comm.Parameters.Add("@disreglev", SqlDbType.VarChar);
comm.Parameters["@disreglev"].Value = drplevel.Trim();
comm.Parameters.Add("@EmphaLevel", SqlDbType.VarChar);
comm.Parameters["@EmphaLevel"].Value = txttrain.Trim();
comm.Parameters.Add("@Award1", SqlDbType.VarChar);
comm.Parameters["@Award1"].Value = txtaward_1.Trim();
comm.Parameters.Add("@Award2", SqlDbType.VarChar);
comm.Parameters["@Award2"].Value = txtaward_2.Trim();
comm.Parameters.Add("@Award3", SqlDbType.VarChar);
comm.Parameters["@Award3"].Value = txtaward_3.Trim();
comm.Parameters.Add("@Award4", SqlDbType.VarChar);
comm.Parameters["@Award4"].Value = txtaward_4.Trim();
suc += comm.ExecuteNonQuery();
comm.Dispose();
}
if (suc > 0) {
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert(' RECORDS SAVED SUCCESSFULLY!');", true);
sqltrans.Commit();
} else {
lblDisplayErr.Text = "COULD NOT SAVE";
}
protected void saverecords() {
try {
int suc = 0;
conn = new SqlConnection(connString);
conn.Open();
sqltrans = conn.BeginTransaction();
string sqldelete = "delete from TrainEmpha where TrainCode = '" + txtcode.Text.ToString().Trim() + "'";
SqlCommand comm = new SqlCommand(sqldelete, conn, sqltrans);
comm.ExecuteNonQuery();
comm.Dispose();
string insertgroup = " Insert into TrainEmpha (TrainCode, TrainDesc,disreglev,EmphaLevel,Award1,Award2,Award3,Award4)" +
" Values (@TrainCode, @TrainDesc,@disreglev,@EmphaLevel,@Award1,@Award2,@Award3,@Award4)";
foreach(GridViewRow gvr in gridview.Rows) {
string drplevel = ((DropDownList) gvr.FindControl("drp_grid_lvl")).Text.Trim();
string txttrain = ((TextBox) gvr.FindControl("txttrained")).Text.Trim();
string txtaward_1 = ((TextBox) gvr.FindControl("txtaward1")).Text.Trim();
string txtaward_2 = ((TextBox) gvr.FindControl("txtaward2")).Text.Trim();
string txtaward_3 = ((TextBox) gvr.FindControl("txtaward3")).Text.Trim();
string txtaward_4 = ((TextBox) gvr.FindControl("txtaward4")).Text.Trim();
comm = new SqlCommand(insertgroup, conn, sqltrans);
comm.Parameters.Add("@TrainCode", SqlDbType.VarChar);
comm.Parameters["@TrainCode"].Value = txtcode.Text.Trim();
comm.Parameters.Add("@TrainDesc", SqlDbType.VarChar);
comm.Parameters["@TrainDesc"].Value = txtdescrip.Text.Trim();
comm.Parameters.Add("@disreglev", SqlDbType.VarChar);
comm.Parameters["@disreglev"].Value = drplevel.Trim();
comm.Parameters.Add("@EmphaLevel", SqlDbType.VarChar);
comm.Parameters["@EmphaLevel"].Value = txttrain.Trim();
comm.Parameters.Add("@Award1", SqlDbType.VarChar);
comm.Parameters["@Award1"].Value = txtaward_1.Trim();
comm.Parameters.Add("@Award2", SqlDbType.VarChar);
comm.Parameters["@Award2"].Value = txtaward_2.Trim();
comm.Parameters.Add("@Award3", SqlDbType.VarChar);
comm.Parameters["@Award3"].Value = txtaward_3.Trim();
comm.Parameters.Add("@Award4", SqlDbType.VarChar);
comm.Parameters["@Award4"].Value = txtaward_4.Trim();
suc += comm.ExecuteNonQuery();
comm.Dispose();
}
if (suc > 0) {
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert(' RECORDS SAVED SUCCESSFULLY!');", true);
sqltrans.Commit();
} else {
lblDisplayErr.Text = "COULD NOT SAVE";
}
protected void saverecords() {
try {
int suc = 0;
conn = new SqlConnection(connString);
conn.Open();
sqltrans = conn.BeginTransaction();
string sqldelete = "delete from TrainEmpha where TrainCode = '" + txtcode.Text.ToString().Trim() + "'";
SqlCommand comm = new SqlCommand(sqldelete, conn, sqltrans);
comm.ExecuteNonQuery();
comm.Dispose();
string insertgroup = " Insert into TrainEmpha (TrainCode, TrainDesc,disreglev,EmphaLevel,Award1,Award2,Award3,Award4)" +
" Values (@TrainCode, @TrainDesc,@disreglev,@EmphaLevel,@Award1,@Award2,@Award3,@Award4)";
foreach(GridViewRow gvr in gridview.Rows) {
string drplevel = ((DropDownList) gvr.FindControl("drp_grid_lvl")).Text.Trim();
string txttrain = ((TextBox) gvr.FindControl("txttrained")).Text.Trim();
string txtaward_1 = ((TextBox) gvr.FindControl("txtaward1")).Text.Trim();
string txtaward_2 = ((TextBox) gvr.FindControl("txtaward2")).Text.Trim();
string txtaward_3 = ((TextBox) gvr.FindControl("txtaward3")).Text.Trim();
string txtaward_4 = ((TextBox) gvr.FindControl("txtaward4")).Text.Trim();
comm = new SqlCommand(insertgroup, conn, sqltrans);
comm.Parameters.Add("@TrainCode", SqlDbType.VarChar);
comm.Parameters["@TrainCode"].Value = txtcode.Text.Trim();
comm.Parameters.Add("@TrainDesc", SqlDbType.VarChar);
comm.Parameters["@TrainDesc"].Value = txtdescrip.Text.Trim();
comm.Parameters.Add("@disreglev", SqlDbType.VarChar);
comm.Parameters["@disreglev"].Value = drplevel.Trim();
comm.Parameters.Add("@EmphaLevel", SqlDbType.VarChar);
comm.Parameters["@EmphaLevel"].Value = txttrain.Trim();
comm.Parameters.Add("@Award1", SqlDbType.VarChar);
comm.Parameters["@Award1"].Value = txtaward_1.Trim();
comm.Parameters.Add("@Award2", SqlDbType.VarChar);
comm.Parameters["@Award2"].Value = txtaward_2.Trim();
comm.Parameters.Add("@Award3", SqlDbType.VarChar);
comm.Parameters["@Award3"].Value = txtaward_3.Trim();
comm.Parameters.Add("@Award4", SqlDbType.VarChar);
comm.Parameters["@Award4"].Value = txtaward_4.Trim();
suc += comm.ExecuteNonQuery();
comm.Dispose();
}
if (suc > 0) {
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert(' RECORDS SAVED SUCCESSFULLY!');", true);
sqltrans.Commit();
} else {
lblDisplayErr.Text = "COULD NOT SAVE";
}
c# asp.net sql-server gridview
c# asp.net sql-server gridview
edited Nov 15 '18 at 9:55
Thilina Nakkawita
9511228
9511228
asked Nov 15 '18 at 8:41
Victor IkpeniVictor Ikpeni
93
93
Are you actually receiving an exception on the call to comm.ExecuteNonQuery(), or are you receiving "COULD NOT SAVE" in your label?
– Allumearz
Nov 15 '18 at 9:01
I receive no message at all
– Victor Ikpeni
Nov 15 '18 at 9:38
If your method is actually getting called, if you are not getting any exceptions, then according to the code you posted, it should always run through the final test of (suc > 0) - therefore you should at least get "COULD NOT SAVE" in lblDisplayErr.Text - have you debugged the application and stepped through the code?
– Allumearz
Nov 15 '18 at 9:45
Ah - I just noticed that the code you posted is partial, and is inside an outer try block. You therefore must be receiving an exception which is jumping out of the try block.
– Allumearz
Nov 15 '18 at 9:48
Can you update your post with the full method code?
– Allumearz
Nov 15 '18 at 9:49
|
show 1 more comment
Are you actually receiving an exception on the call to comm.ExecuteNonQuery(), or are you receiving "COULD NOT SAVE" in your label?
– Allumearz
Nov 15 '18 at 9:01
I receive no message at all
– Victor Ikpeni
Nov 15 '18 at 9:38
If your method is actually getting called, if you are not getting any exceptions, then according to the code you posted, it should always run through the final test of (suc > 0) - therefore you should at least get "COULD NOT SAVE" in lblDisplayErr.Text - have you debugged the application and stepped through the code?
– Allumearz
Nov 15 '18 at 9:45
Ah - I just noticed that the code you posted is partial, and is inside an outer try block. You therefore must be receiving an exception which is jumping out of the try block.
– Allumearz
Nov 15 '18 at 9:48
Can you update your post with the full method code?
– Allumearz
Nov 15 '18 at 9:49
Are you actually receiving an exception on the call to comm.ExecuteNonQuery(), or are you receiving "COULD NOT SAVE" in your label?
– Allumearz
Nov 15 '18 at 9:01
Are you actually receiving an exception on the call to comm.ExecuteNonQuery(), or are you receiving "COULD NOT SAVE" in your label?
– Allumearz
Nov 15 '18 at 9:01
I receive no message at all
– Victor Ikpeni
Nov 15 '18 at 9:38
I receive no message at all
– Victor Ikpeni
Nov 15 '18 at 9:38
If your method is actually getting called, if you are not getting any exceptions, then according to the code you posted, it should always run through the final test of (suc > 0) - therefore you should at least get "COULD NOT SAVE" in lblDisplayErr.Text - have you debugged the application and stepped through the code?
– Allumearz
Nov 15 '18 at 9:45
If your method is actually getting called, if you are not getting any exceptions, then according to the code you posted, it should always run through the final test of (suc > 0) - therefore you should at least get "COULD NOT SAVE" in lblDisplayErr.Text - have you debugged the application and stepped through the code?
– Allumearz
Nov 15 '18 at 9:45
Ah - I just noticed that the code you posted is partial, and is inside an outer try block. You therefore must be receiving an exception which is jumping out of the try block.
– Allumearz
Nov 15 '18 at 9:48
Ah - I just noticed that the code you posted is partial, and is inside an outer try block. You therefore must be receiving an exception which is jumping out of the try block.
– Allumearz
Nov 15 '18 at 9:48
Can you update your post with the full method code?
– Allumearz
Nov 15 '18 at 9:49
Can you update your post with the full method code?
– Allumearz
Nov 15 '18 at 9:49
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315369%2fsaving-data-entered-in-gridview-using-c-sharp-and-sqlserver%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315369%2fsaving-data-entered-in-gridview-using-c-sharp-and-sqlserver%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you actually receiving an exception on the call to comm.ExecuteNonQuery(), or are you receiving "COULD NOT SAVE" in your label?
– Allumearz
Nov 15 '18 at 9:01
I receive no message at all
– Victor Ikpeni
Nov 15 '18 at 9:38
If your method is actually getting called, if you are not getting any exceptions, then according to the code you posted, it should always run through the final test of (suc > 0) - therefore you should at least get "COULD NOT SAVE" in lblDisplayErr.Text - have you debugged the application and stepped through the code?
– Allumearz
Nov 15 '18 at 9:45
Ah - I just noticed that the code you posted is partial, and is inside an outer try block. You therefore must be receiving an exception which is jumping out of the try block.
– Allumearz
Nov 15 '18 at 9:48
Can you update your post with the full method code?
– Allumearz
Nov 15 '18 at 9:49