Results 1 to 5 of 5

Thread: how to use the SqlCommand.Parameters thing?

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    how to use the SqlCommand.Parameters thing?

    i can add parameters to it..but how do i set if i wanna do a Insert/Delete etc statement in the sql database?
    \m/\m/

  2. #2

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    bump!
    \m/\m/

  3. #3
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    For an insert do this
    Code:
    string sqlString = "INSERT INTO MyTable(fname, lname, city) VALUES(@fname, @lname, @city)";
    
    SqlCommand cmd = new SqlCommand(sqlString, sqlConnection);
    
    cmd.Parameters.Add("@fname", "Dev");
    cmd.Parameters.Add("@lname", "Group");
    cmd.Parameters.Add("@city", "Brooklyn");
    For a delete
    Code:
    string sqlString = "DELETE FROM MyTable WHERE fname = @fname";
    
    SqlCommand cmd = new SqlCommand(sqlString, sqlConnection);
    
    cmd.Parameters.Add("@fname", "Dev");

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    tks by the answer but i've already had figured it out by your web log source code! tks anyways!
    \m/\m/

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    No prob

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width