Temp table I assign the values I read in excel table.If the temp table and student table are different, I want to add different ones to the student table.But I can't add with these operations.How can I do it. The SQL command is giving an error and I can't calculate whether it has an int value.
What I have tried:
using(var different=new SqlCommand("SELECT ID,Name,Surname from ##mytemptable except SELECT ID,Name,Surname from Student)),connection)
SqlDataReader dr =different.ExecuteReader();
int newdifferentvalue=0;
if(dr.Read())
{
newdifferentvalue=dr.GetInt32(0);
using(var different=new SqlCommand("INSERT INTO ID,Name,Surname from Student (SELECT ID,Name,Surname from ##mytemptable except SELECT ID,Name,Surname from Student)),connection)
MessageBox.Show("Different Information is added");
}
else
{
<pre>MessageBox.Show("Different Information has no value.So not added.");
}