My program Reads variables from DB Successfully
But i have a problem in inserting data into it
i don't know why ?
i use this code in more programs and it works good
C# Class Code
class Gesture
{
SqlConnection con1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Amr Khalid\Documents\HandGestures.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
public void Addgesture(int i , string blue, string red, string green, string yellow, string magenta , string control)
{
SqlCommand mycom2 = new SqlCommand();
mycom2.Connection = con1;
mycom2.CommandType = CommandType.StoredProcedure;
mycom2.CommandText = "AddGesture";
mycom2.Parameters.AddWithValue("@int", i);
mycom2.Parameters.AddWithValue("@blue", blue);
mycom2.Parameters.AddWithValue("@red", red);
mycom2.Parameters.AddWithValue("@green", green);
mycom2.Parameters.AddWithValue("@yellow", yellow);
mycom2.Parameters.AddWithValue("@magenta", magenta);
mycom2.Parameters.AddWithValue("@Control", control);
con1.Open();
mycom2.ExecuteNonQuery();
con1.Close();
}
}
C# Program Code
int i = 77;
string control = comboBox1.Items.ToString();
Gesture newg = new Gesture();
newg.Addgesture(i, FBlue2, FRed2, FGreen2, FYellow2, FMagenta2, control);
StoredProcedure SQL code
ALTER PROCEDURE AddGesture
@int int ,@blue varchar(50) , @red varchar(50) ,@green varchar(50) ,@yellow varchar(50) , @magenta varchar(50) , @Control varchar(50)
AS
Insert into Gesture values (@int ,@blue,@red,@green,@yellow,@magenta,@Control)
RETURN
>>>>>>>>>>>>>>>>>
i have the problem in
mycom2.ExecuteNonQuery();
The error is
Invalid object name 'Gesture'.
[edit]Code block added - OriginalGriff[/edit]