private string conString = "Data Source=iroshanlap;Initial Catalog=test;User Id=sa;Password=p@ssw0rd;";
SqlConnection con = new SqlConnection(conString);
con.Open();
try
{
SqlCommand command = new SqlCommand("InsertFileData", con);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@FileName", SqlDbType.NVarChar, 200, "FileName"));
command.Parameters.Add(new SqlParameter("@FileData", SqlDbType.NVarChar, 4000, "FileData"));
foreach (DataRow dr in dt.Rows)
{
command.Parameters[0].Value = dr[0].ToString();
command.Parameters[1].Value = dr[1].ToString();
int i = command.ExecuteNonQuery();
}
}
catch (Exception ex)
{
string s = ex.Message;
}
finally
{
con.Close();
}
No comments:
Post a Comment