Click here to Skip to main content
16,011,626 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SqlDataReader reader = cmd.ExecuteReader();
SQL
ALTER procedure [dbo].[sp_files] @filename nvarchar(50),@invID int,@filepath nvarchar(max),
@filesize decimal,@fileCreateddt datetime
as
begin
insert into [dbo].[tblFiles](fileName,invID,fileSize,filePath,fileCreatedDt) values(@filename,@invID,@filesize,@filepath,@fileCreateddt)
end






I am getting the above mentioned errror....Pls help me out
Posted
Comments
Sascha Lefèvre 23-Apr-15 2:28am    
Please post your C#-code (not just that single line, it doesn't help)
Thanks7872 23-Apr-15 2:31am    
Error is pretty self explanatory. It needs one parameter which you are not providing. Pass it from code along with other parameters.
Maciej Los 23-Apr-15 2:40am    
My virtual 5!
Thanks7872 23-Apr-15 3:26am    
:)

There are some parameters in the SP that need to be passed via the code.
These are the parameters -
SQL
@filename nvarchar(50),
@invID int,
@filepath nvarchar(max),
@filesize decimal,
@fileCreateddt datetime


To learn more about passing parameters in an SP go through -
C# Stored Procedure with Parameter [^]
Using parameterized SP's in ADO.Net[^]
 
Share this answer
 
You need to pass parameters to you procedure

string filename = "";
cmd.Parameters.AddWithValue("@filename", filename);
.
.
.
Similarly for all the parameters you are using in your procedure
 
Share this answer
 
SQL
ALTER procedure [dbo].[sp_files] 
@filename nvarchar(50),
@invID int,
@filepath nvarchar(max),
@filesize decimal,
@fileCreateddt datetime
as
begin
insert into [dbo].[tblFiles](fileName,invID,fileSize,filePath,fileCreatedDt) values(@filename,@invID,@filesize,@filepath,@fileCreateddt)
end


and C# code:-

C#
private void button1_Click(object sender, EventArgs e) {
  using (SqlConnection con = new SqlConnection(dc.Con)) {
    using (SqlCommand cmd = new SqlCommand("storedprocedure", con)) {
      cmd.CommandType = CommandType.StoredProcedure;

      cmd.Parameters.Add("@filename", SqlDbType.VarChar).Value = txtFirstName.Text;
      cmd.Parameters.Add("@invID", SqlDbType.VarChar).Value = txtLastName.Text;

      con.Open();
      cmd.ExecuteNonQuery();
    }
  }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900