below is my code: it is different one from question posted before.
SqlConnection con = new SqlConnection(conn);
con.Open();
SqlCommand com = new SqlCommand("INSERT into test",con);
com.CommandType = CommandType.StoredProcedure;
com.Connection = con;
com.Parameters.AddWithValue("@fileupload1", s1);
com.Parameters.AddWithValue("@path", path).ToString();
com.Parameters.AddWithValue("@Availability",Availability.SelectedValue).ToString();
[![enter image description here][1]][1]
Since the content of your command is a query statement and not a stored procedure, use the relevant enumeration value :
// ...
SqlCommand com = new SqlCommand("INSERT into test",con);
com.CommandType = CommandType.Text;
// ...
But bare in mind your command parameters are unused in this query.
With the SqlCommand constructor you are using, the first argument is either the stored procedure name or a query. You have provided a query, but you have set the CommandType to StoredProcedure. Either change the first argument to a stored procedure name or leave the CommandType to the default.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.