Hello,
I feel this code must solve your query
using System.Data.SqlClient;
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.;Initial Catalog=RJIT;Integrated Security=True";
con.Open();
string mycommand = "insert into receipt values(@student_id,@amount_paid,@student_name)";
SqlCommand cmd = new SqlCommand(mycommand, con);
cmd.Parameters.AddWithValue("@student_id", comboBox1.Text);
cmd.Parameters.AddWithValue("@amount_paid", txtreceiptstudamount.Text);
cmd.Parameters.AddWithValue("@student_name", txtreceiptstudname.Text);
int x = cmd.ExecuteNonQuery();
if (x != 0)
{
MessageBox.Show("Data added");
}
con.Close();
Do rate my answer once you find it useful
Thanks & Regards
Radix :rose: