Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

I am having trouble inserting Strings and Chars into my database through variables. If I put a number into the variable it will insert, if it is any type of character or string of characters, it will not. In this example, the variable theOption and number would insert into the database fine. However, theAnswer (which includes a string of chars in it) will not insert. In the database, surveyID is numeric, questionID is an int, optionID is a varchar (length 2) and answer is a varchar (length 5000). Any help would be great thnx.

 

int number = 12;

String theOption = "1";

String theAnswer = "aba";

myCmd.CommandText = "INSERT INTO response(surveyID, questionID, optionID, answer) VALUES(123," + number + "," + theOption + "," + theAnswer + ")";

 

I am running VS .net 2003, my DB is SQL Server 2000, and the language is C#.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...