How to insert an integer into a database through command prompt

Posted by jpavlov on Stack Overflow See other posts from Stack Overflow or by jpavlov
Published on 2011-01-10T18:52:16Z Indexed on 2011/01/10 18:53 UTC
Read the original article Hit count: 233

Filed under:
|

I am trying to insert a integer into a database in C# using the code below, but everytime I run the compiler informs me that my integer is not a valid column "Invalid Column Name UserID"

Does anyone have any insight on this? Thanks.

Console.WriteLine("Please enter a new User Id");
        string line = Console.ReadLine();
        int UserID;
        if (int.TryParse(line, out UserID))
        {
            Console.WriteLine(UserID);
            Console.ReadLine();
        }



        //Prepare the command string
        string insertString = @"INSERT INTO tb_User(ID,f_Name, l_Name) VALUES (UserID,'Ted','Turner')";

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql