Hello
I searched through this site and found some topic about my problem but still cannot make this work....
I am simply trying to retrieve data from SQL Database using a stored procedure.
I am passing one parameter that is a SqlDbType.Varchar(50) type, but get back an SQL error:
Procedure or function 'WyszukajPrzesylki' expects parameter '@Nazwisko', which was not supplied.
What am I doing wrong? Store procedure works if I test it in SSMS ...
It even works when I type
SqlCommand com = new SqlCommand("WyszukajPrzesylki @Nazwisko = Example", con);
You are my last hope guys... I've already lost 2 days with this problem and cannot get any further... don't have any problems with inserting and updating records using c# ... just this....
So here is the code of SP
ALTER PROCEDURE [dbo].[WyszukajPrzesylki]
@Nazwisko varchar(50)
AS
BEGIN
SET NOCOUNT ON;
SELECT * FROM Przesylki WHERE (Przesylki.NazwiskoAdresata = @Nazwisko)
END
and action of the button:
SqlConnection con = new SqlConnection(Properties.Settings.Default.Monitoring_PrzesylekString1);
SqlCommand com = new SqlCommand("WyszukajPrzesylki", con);
com.CommandType = CommandType.StoredProcedure;
SqlParameter parametrNazwisko = new SqlParameter("@Nazwisko", SqlDbType.VarChar, 50);
parametrNazwisko.Value = "Dziubak";
com.Parameters.Add(parametrNazwisko);
SqlDataAdapter ad = new SqlDataAdapter(com.CommandText, con);
DataSet ds = new DataSet();
ad.Fill(ds, "id");
con.Close();
DataTable datatableA = ds.Tables[0];
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "id";