how to insert into specific column in a new multi column table in sql table

KwebenaAcquah-9104 306 Reputation points
2021-03-22T02:27:06.297+00:00

how can i do this

sqlcommand cmd= new sqlcommand("INSERT INTO tbl_A (columnA, columnB,
columnC)VALUES (@columnA, @columnB, @columnC)",conn);
cmd.parameter.Addwithvalue ("@columnA", textboxA);
cmd.parameter.ADdwithvalue("@columnB", textboxB);
cmd.ExecuteNonQuery();

is it possible to insert only on two columns when i have more than two columns in my sql table please can some one help me to achieve this.

i tried this code below:

SqlConnection Conn = new SqlConnection(shoolmanangmentconn);
                            Conn.Open();
                            SqlCommand cmd = new SqlCommand("INSERT INTO tbl_TestingThatSubjects(INDO, LANGUAGE,BIOLOGY, GEOGRAPHY) VALUES (@IDNO,@LANGUAGE,@BIOLOGY,@GEOGRAPHY)", Conn);
                            cmd.Parameters.AddWithValue("@IDNO", txtids.Text); 
                            cmd.Parameters.AddWithValue("@LANGUAGE", txtlanguage.Text);
                            cmd.ExecuteNonQuery();

i am trying to insert into only at column LANGUAGE without inserting into other columns
please can someone teach me how to do the right thing. (am using wpf c#)

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,676 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,278 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 112.5K Reputation points
    2021-03-22T10:25:33.097+00:00

    If the row already exists, then use UPDATE:

    . . .
    SqlCommand cmd = new SqlCommand("UPDATE tbl_TestingThatSubjects SET [LANGUAGE] = @LANGUAGE WHERE IDNO = @IDNO", 
    Conn);
    . . .
    
    0 comments No comments