1

私のシステムにはエラーはありませんが、追加しようとしても tblHardware に何も追加されません。これは私のコードです。

private void btnTilfoj_Click(object sender, EventArgs e)
{
    conn = new SqlConnection(connectionstring);
    conn.Open();
    commandstring = "INSERT INTO tblItUdstyr([HardwareType], [KobsDato], [SerieNr]) VALUES(@HardwareType, @KobsDato, @SerieNr)";
    comm = new SqlCommand(commandstring, conn);

    comm.Parameters.Add("@HardwareType", SqlDbType.VarChar);
    comm.Parameters["@HardwareType"].Value = cbHardware.Text.ToString();

    comm.Parameters.Add("@KobsDato", SqlDbType.Date);
    comm.Parameters["@KobsDato"].Value = dtpKobsDato.Value;

    comm.Parameters.Add("@SerieNr", SqlDbType.VarChar);
    comm.Parameters["@SerieNr"].Value = txtSerienr.Text.ToString();
}
4

2 に答える 2