sql server2000 "insert" in c# .net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sowmyat
    New Member
    • Feb 2007
    • 6

    sql server2000 "insert" in c# .net

    hi Guys,

    i developed one web based application in c# .net & with ASP .net.In that i put connection to a database in sql server 2000.how can i insert the values which are in a variable to the database.
    i wrote like this,

    string s="abc";
    thisCommand3.Co mmandText = "insert into results values ( 'sowmya',1,"+s+ " 'ravi')";

    but i am getting error.
    can any one know this.
    plz help.........
  • nmsreddi
    Contributor
    • Jul 2006
    • 366

    #2
    Hello

    try this one

    thisCommand3.Co mmandText = "insert into results values ( 'sowmya',1,'"+s+"', 'ravi')";

    you are missing singlecodes along with doublecode while passing parameter

    and make that results table contains all the which you are inserting and datatypes are correct

    Good luck

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      If that gives you an error try:

      thisCommand3.Co mmandText = "insert into results values ( 'sowmya',1,'" & s & "', 'ravi')";

      Comment

      • sowmyat
        New Member
        • Feb 2007
        • 6

        #4
        thank u
        i got it

        Comment

        Working...