hi,
here is the code example
protected void Upload_Click(object sender, EventArgs e)
{
string picUrl;
if (FileUpload1.HasFile)
{
picUrl = FileUpload1.PostedFile.FileName;
FileUpload1.SaveAs("c:\\"+FileUpload1.FileName);
insertUrl(picUrl);
}
}
void insertUrl(string url)
{
string co = "Data Source=localhost\\sqlexpress;Initial Catalog=pubs;Integrated Security=True";
System.Data.SqlClient.SqlConnection sqlconnect = new System.Data.SqlClient.SqlConnection(co);
System.Data.SqlClient.SqlCommand sqlcommand = new System.Data.SqlClient.SqlCommand();
sqlcommand.CommandText = "insert into test values(@project,@picUrl)";
sqlcommand.Connection = sqlconnect;
System.Data.SqlClient.SqlParameter p1 = new System.Data.SqlClient.SqlParameter();
p1.ParameterName = "@project";
p1.Value = "1";
p1.SqlDbType = System.Data.SqlDbType.VarChar;
sqlcommand.Parameters.Add(p1);
System.Data.SqlClient.SqlParameter p2 = new System.Data.SqlClient.SqlParameter();
p2.ParameterName = "@picUrl";
p2.Value = url;
p2.SqlDbType = System.Data.SqlDbType.VarChar;
sqlcommand.Parameters.Add(p2);
sqlconnect.Open();
sqlcommand.ExecuteNonQuery();
sqlconnect.Close();
}