Why i can not add data into new added column
I am amateur C# developer.Now i'm working on destkop application and work with MS2015 and SQL Management Studio.I have added new column into my database and write what is needed for it in .cs code,but can not add my data into column.It always shows NULL even if it is not empty.Here is my code about saving data:
private void btnSave_Click(object sender, EventArgs e) txtQuantity.Text == ""
c# sql-server
add a comment |
I am amateur C# developer.Now i'm working on destkop application and work with MS2015 and SQL Management Studio.I have added new column into my database and write what is needed for it in .cs code,but can not add my data into column.It always shows NULL even if it is not empty.Here is my code about saving data:
private void btnSave_Click(object sender, EventArgs e) txtQuantity.Text == ""
c# sql-server
Amount is my new column
– Nicat101
Nov 13 '18 at 19:57
I think before updating the state of model, you need to attach it. Like - db.Tables.Attach(model); and then you modify the state and save.
– Piyush Khanna
Nov 13 '18 at 20:10
Sir,i have done it but it did not solve the problem
– Nicat101
Nov 14 '18 at 8:32
add a comment |
I am amateur C# developer.Now i'm working on destkop application and work with MS2015 and SQL Management Studio.I have added new column into my database and write what is needed for it in .cs code,but can not add my data into column.It always shows NULL even if it is not empty.Here is my code about saving data:
private void btnSave_Click(object sender, EventArgs e) txtQuantity.Text == ""
c# sql-server
I am amateur C# developer.Now i'm working on destkop application and work with MS2015 and SQL Management Studio.I have added new column into my database and write what is needed for it in .cs code,but can not add my data into column.It always shows NULL even if it is not empty.Here is my code about saving data:
private void btnSave_Click(object sender, EventArgs e) txtQuantity.Text == ""
c# sql-server
c# sql-server
edited Nov 13 '18 at 20:00
jdweng
17.4k2717
17.4k2717
asked Nov 13 '18 at 19:54
Nicat101Nicat101
12
12
Amount is my new column
– Nicat101
Nov 13 '18 at 19:57
I think before updating the state of model, you need to attach it. Like - db.Tables.Attach(model); and then you modify the state and save.
– Piyush Khanna
Nov 13 '18 at 20:10
Sir,i have done it but it did not solve the problem
– Nicat101
Nov 14 '18 at 8:32
add a comment |
Amount is my new column
– Nicat101
Nov 13 '18 at 19:57
I think before updating the state of model, you need to attach it. Like - db.Tables.Attach(model); and then you modify the state and save.
– Piyush Khanna
Nov 13 '18 at 20:10
Sir,i have done it but it did not solve the problem
– Nicat101
Nov 14 '18 at 8:32
Amount is my new column
– Nicat101
Nov 13 '18 at 19:57
Amount is my new column
– Nicat101
Nov 13 '18 at 19:57
I think before updating the state of model, you need to attach it. Like - db.Tables.Attach(model); and then you modify the state and save.
– Piyush Khanna
Nov 13 '18 at 20:10
I think before updating the state of model, you need to attach it. Like - db.Tables.Attach(model); and then you modify the state and save.
– Piyush Khanna
Nov 13 '18 at 20:10
Sir,i have done it but it did not solve the problem
– Nicat101
Nov 14 '18 at 8:32
Sir,i have done it but it did not solve the problem
– Nicat101
Nov 14 '18 at 8:32
add a comment |
1 Answer
1
active
oldest
votes
If you add an exception handler, it will tell you what's wrong.
Wrap your code in a try/catch block.
try
// your code goes here
catch(Exception ex)
Debug.Writeln(ex.Message);
Terry Carmen,sir i used try/catch block but it showed no problem
– Nicat101
Nov 14 '18 at 7:44
add a comment |
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%2f53288544%2fwhy-i-can-not-add-data-into-new-added-column%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you add an exception handler, it will tell you what's wrong.
Wrap your code in a try/catch block.
try
// your code goes here
catch(Exception ex)
Debug.Writeln(ex.Message);
Terry Carmen,sir i used try/catch block but it showed no problem
– Nicat101
Nov 14 '18 at 7:44
add a comment |
If you add an exception handler, it will tell you what's wrong.
Wrap your code in a try/catch block.
try
// your code goes here
catch(Exception ex)
Debug.Writeln(ex.Message);
Terry Carmen,sir i used try/catch block but it showed no problem
– Nicat101
Nov 14 '18 at 7:44
add a comment |
If you add an exception handler, it will tell you what's wrong.
Wrap your code in a try/catch block.
try
// your code goes here
catch(Exception ex)
Debug.Writeln(ex.Message);
If you add an exception handler, it will tell you what's wrong.
Wrap your code in a try/catch block.
try
// your code goes here
catch(Exception ex)
Debug.Writeln(ex.Message);
answered Nov 13 '18 at 20:42
Terry CarmenTerry Carmen
2,5591818
2,5591818
Terry Carmen,sir i used try/catch block but it showed no problem
– Nicat101
Nov 14 '18 at 7:44
add a comment |
Terry Carmen,sir i used try/catch block but it showed no problem
– Nicat101
Nov 14 '18 at 7:44
Terry Carmen,sir i used try/catch block but it showed no problem
– Nicat101
Nov 14 '18 at 7:44
Terry Carmen,sir i used try/catch block but it showed no problem
– Nicat101
Nov 14 '18 at 7:44
add a comment |
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%2f53288544%2fwhy-i-can-not-add-data-into-new-added-column%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
Amount is my new column
– Nicat101
Nov 13 '18 at 19:57
I think before updating the state of model, you need to attach it. Like - db.Tables.Attach(model); and then you modify the state and save.
– Piyush Khanna
Nov 13 '18 at 20:10
Sir,i have done it but it did not solve the problem
– Nicat101
Nov 14 '18 at 8:32