G
Guest
hi,
Can anybody tell me that thru asp.net using c#, how can we upload and
download physical files in any table of SQL Server Database.
the uploading part is running successfully but the problem arises in the
retriving part of the code.
i am not getting that how will i able to download the file which is there in
the SQL Server database in the field type "image".
here is the code by which i am uploading any file to the my SQL Server
database
private void btnUpload_Click(object sender, System.EventArgs e)
{
HttpPostedFile filPosted = filUpload.PostedFile;
int intFileLength = System.Convert.ToInt32(filPosted.ContentLength);
byte[] byteData = new byte[intFileLength];
filPosted.InputStream.Read(byteData, 0, intFileLength);
Conn.OpenConnection();
string sql="Insert into
HRRecruitmentMaster(CandidateName,HighestQualificationID,JobFieldID,TotalExperienceInYears,CandidatePresentLocation,FileName,CandidateResume,type,length)
Values (@CandidateName," + cmbHighestQuali.SelectedValue + "," +
cmbJobField.SelectedValue + "," + txtTotalExp.Text + ",'" +
txtPresentLoc.Text + "',@FileName,@CandidateResume,@Type," + intFileLength +
")";
SqlCommand Cmd = new SqlCommand();
Cmd.CommandText=sql;
Cmd.Connection =Conn.Cn;
Cmd.Parameters.Add("@CandidateName",txtCandidateName.Text)
Cmd.Parameters.Add("@FileName",System.IO.Path.GetFileName(filPosted.FileName))
Cmd.Parameters.Add("@CandidateResume",System.Data.SqlDbType.Image,intFileLength);
Cmd.Parameters["@CandidateResume"].Value=byteData;
Cmd.Parameters.Add("@Type",filPosted.ContentType);
Cmd.ExecuteNonQuery();
Conn.CloseConnection();
}
so pls. help me out in this matter i'll be very much grateful to u
Regards
Himanshu Saxena
Sahara India
India
Can anybody tell me that thru asp.net using c#, how can we upload and
download physical files in any table of SQL Server Database.
the uploading part is running successfully but the problem arises in the
retriving part of the code.
i am not getting that how will i able to download the file which is there in
the SQL Server database in the field type "image".
here is the code by which i am uploading any file to the my SQL Server
database
private void btnUpload_Click(object sender, System.EventArgs e)
{
HttpPostedFile filPosted = filUpload.PostedFile;
int intFileLength = System.Convert.ToInt32(filPosted.ContentLength);
byte[] byteData = new byte[intFileLength];
filPosted.InputStream.Read(byteData, 0, intFileLength);
Conn.OpenConnection();
string sql="Insert into
HRRecruitmentMaster(CandidateName,HighestQualificationID,JobFieldID,TotalExperienceInYears,CandidatePresentLocation,FileName,CandidateResume,type,length)
Values (@CandidateName," + cmbHighestQuali.SelectedValue + "," +
cmbJobField.SelectedValue + "," + txtTotalExp.Text + ",'" +
txtPresentLoc.Text + "',@FileName,@CandidateResume,@Type," + intFileLength +
")";
SqlCommand Cmd = new SqlCommand();
Cmd.CommandText=sql;
Cmd.Connection =Conn.Cn;
Cmd.Parameters.Add("@CandidateName",txtCandidateName.Text)
Cmd.Parameters.Add("@FileName",System.IO.Path.GetFileName(filPosted.FileName))
Cmd.Parameters.Add("@CandidateResume",System.Data.SqlDbType.Image,intFileLength);
Cmd.Parameters["@CandidateResume"].Value=byteData;
Cmd.Parameters.Add("@Type",filPosted.ContentType);
Cmd.ExecuteNonQuery();
Conn.CloseConnection();
}
so pls. help me out in this matter i'll be very much grateful to u
Regards
Himanshu Saxena
Sahara India
India