3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by __avd
0

Welcome nverma.
What do you mean by saving a file in a database?
Show us the code you already have. And if you do so PLEASE use code tags.

0

Welcome nverma.
What do you mean by saving a file in a database?
Show us the code you already have. And if you do so PLEASE use code tags.

i have used a FileUpload control to allow user to upload a file (a word document or an excel sheet) and saving this file to my ms access data base.On submit button i'm using the following code:

string con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/C1/App_Data/db4.mdb;Persist Security Info=False";

string q="insert into table(fname,fcontent) values('"+this.FileUpload.Text+"','"+this.FileUpload.Content+"');

OleDbConnection cn = new OleDbConnection(con);
cn.Open();
OleDbCommand cmd = new OleDbCommand(q, cn);
cmd.ExecuteNonQuery();
cn.Close();

0

Use parameterized query. fcontent field type must be binary (blob/image) ole or something with access db.

string con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/C1/App_Data/db4.mdb;Persist Security Info=False";
string q="insert into table(fname,fcontent) values(?,?)"
...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.