hi all
i make a store procdeure in visual studio wpf when i run a code the error is not solve
here is error
"Procedure getguestinfo has no parameters and arguments were supplied."
and here is the code
public class guests
{
private int guest_id;
public int Guest_id
{
get { return guest_id; }
set { guest_id = value; }
}
private string first_name;
public string First_name
{
get { return first_name; }
set { first_name = value; }
}
private string last_name;
public string Last_name
{
get { return last_name; }
set { last_name = value; }
}
private string gender_status;
public string Gender_status
{
get { return gender_status; }
set { gender_status = value; }
}
private string martial_status;
public string Martial_status
{
get { return martial_status; }
set { martial_status = value; }
}
private int phone_numb;
public int Phone_numb
{
get { return phone_numb; }
set { phone_numb = value; }
}
private string email_id;
public string Email_id
{
get { return email_id; }
set { email_id = value; }
}
DataSet ds = new DataSet();
public string displaydata()
{
string ConString = @"Data source = .\SqlExpress ; Database=htm ;Integrated security=true";
SqlConnection con = new SqlConnection(ConString);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand("select * from guestinfo");
da.Fill(ds);
ds.Clear();
return "done";
}
public void add()
{
guests gus = new guests();
string ConString = @"Data Source=USER-PC\SQLEXPRESS;Initial Catalog=htm;Integrated Security=True";
SqlConnection con = new SqlConnection(ConString);
//string query = "Insert into GuestInfo(Guest ID,first name,last name,gender,martial status,phone number,email_address) values (" + guest_id + ",'" + first_name + "','" + last_name + "','" + gender_status + "','" + martial_status + "','" + phone_numb + "','" + email_id + "')";
//SqlCommand cmd = new SqlCommand(query, con);
con.Open();
SqlCommand com = new SqlCommand("getguestinfo", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add(new SqlParameter("@guestid", gus.guest_id));
com.Parameters.Add(new SqlParameter("@firstname", gus.first_name));
com.Parameters.Add(new SqlParameter("@lastname", gus.last_name));
com.Parameters.Add(new SqlParameter("@gender", gus.gender_status));
com.Parameters.Add(new SqlParameter("@martialsttus", gus.martial_status));
com.Parameters.Add(new SqlParameter("@phonenumber", gus.phone_numb));
com.Parameters.Add(new SqlParameter("@mailid", gus.email_id));
//int id = Convert.ToInt32(
com.ExecuteNonQuery();
con.Close();
// return id;
back to the form coding is
private void button8_Click(object sender, EventArgs e)
{
guests sgt=new guests();
sgt.add();
}
private void button5_Click(object sender, EventArgs e)
{
tabControl1.SelectedIndex = 1;
guests gst = new guests();
gst.Guest_id = Convert.ToInt32(guest_id.Text.ToString());
gst.First_name = first_name.Text.ToString();
gst.Last_name = last_name.Text.ToString();
gst.Gender_status = gender_status.Text.ToString();
gst.Martial_status = martial_status.Text.ToString();
// gst.Phone_numb = Convert.ToInt32(phone_numb.ToString());
gst.Email_id = email_id.Text.ToString();
gst.add();
dataGridView1.DataSource = gst.displaydata();
}
and here is stored procedure code
ALTER Procedure getguestinfo
as
Select * from GuestInfo As G
anyone tell about this problem????