Click here to Skip to main content
15,915,513 members
Home / Discussions / C#
   

C#

 
GeneralRe: get a value from database into a variable. Pin
Nekshan7-Feb-07 18:44
Nekshan7-Feb-07 18:44 
GeneralRe: get a value from database into a variable. Pin
Christian Graus7-Feb-07 18:55
protectorChristian Graus7-Feb-07 18:55 
GeneralRe: get a value from database into a variable. Pin
B.A7-Feb-07 19:04
B.A7-Feb-07 19:04 
GeneralRe: get a value from database into a variable. Pin
Nekshan7-Feb-07 19:36
Nekshan7-Feb-07 19:36 
GeneralRe: get a value from database into a variable. Pin
Christian Graus7-Feb-07 21:01
protectorChristian Graus7-Feb-07 21:01 
GeneralRe: get a value from database into a variable. Pin
Christian Graus7-Feb-07 21:00
protectorChristian Graus7-Feb-07 21:00 
GeneralRe: get a value from database into a variable. Pin
Nekshan7-Feb-07 22:37
Nekshan7-Feb-07 22:37 
GeneralRe: get a value from database into a variable. Pin
Stefan Troschuetz7-Feb-07 22:56
Stefan Troschuetz7-Feb-07 22:56 
As Christian said before, you should definitely go out and buy you a book on C# and database programming.
Obviously, you still not get the idea that s is just a plain string that contains the text of your query, but the string itself cannot return the result of the query. That's what the classes inside the System.Data namespace are for. You already set up a SqlCommand instance in your code snippet, so why are you still trying to get the query result from the query string.? You should get the id by calling ExecuteScalar instead of ExecuteNonQuery on the SqlCommand instance and cast it to int. Take a look at the MSDN topic of the ExecuteScalar method; it contains an example that is similar to what you're trying to achieve.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

www.troschuetz.de

GeneralRe: get a value from database into a variable. Pin
Christian Graus7-Feb-07 23:25
protectorChristian Graus7-Feb-07 23:25 
AnswerRe: get a value from database into a variable. Pin
Dhaval Makhecha8-Feb-07 20:06
Dhaval Makhecha8-Feb-07 20:06 
GeneralRe: get a value from database into a variable. Pin
Nekshan8-Feb-07 22:18
Nekshan8-Feb-07 22:18 
QuestionHelp in implementing Cascaded style sheet in Visual studio.net 2003 Pin
EEmaan7-Feb-07 18:11
EEmaan7-Feb-07 18:11 
AnswerRe: Help in implementing Cascaded style sheet in Visual studio.net 2003 Pin
Christian Graus7-Feb-07 18:22
protectorChristian Graus7-Feb-07 18:22 
Questionconcatenate SortedList Pin
swjam7-Feb-07 17:52
swjam7-Feb-07 17:52 
Questionsource code to draw an ellipse by pressing a button Pin
giovannirodrigo7-Feb-07 16:59
giovannirodrigo7-Feb-07 16:59 
AnswerRe: source code to draw an ellipse by pressing a button Pin
Christian Graus7-Feb-07 17:39
protectorChristian Graus7-Feb-07 17:39 
GeneralRe: source code to draw an ellipse by pressing a button Pin
giovannirodrigo8-Feb-07 2:52
giovannirodrigo8-Feb-07 2:52 
GeneralRe: source code to draw an ellipse by pressing a button Pin
Christian Graus8-Feb-07 8:42
protectorChristian Graus8-Feb-07 8:42 
QuestionPlz help me in using Media player control in C# Asp.net web application Pin
EEmaan7-Feb-07 16:54
EEmaan7-Feb-07 16:54 
AnswerRe: Plz help me in using Media player control in C# Asp.net web application Pin
Christian Graus7-Feb-07 17:48
protectorChristian Graus7-Feb-07 17:48 
QuestionHow to draw an ellipse by pressing a button Pin
giovannirodrigo7-Feb-07 16:33
giovannirodrigo7-Feb-07 16:33 
AnswerRe: How to draw an ellipse by pressing a button Pin
Christian Graus7-Feb-07 16:37
protectorChristian Graus7-Feb-07 16:37 
NewsDrp System sourcecode Pin
tangmin20087-Feb-07 16:25
tangmin20087-Feb-07 16:25 
GeneralRe: Drp System sourcecode Pin
Christian Graus7-Feb-07 16:38
protectorChristian Graus7-Feb-07 16:38 
QuestionSystem.Drawing Pin
dsl/fahk7-Feb-07 16:00
dsl/fahk7-Feb-07 16:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.