Tuesday, July 1, 2008

Save File to FireBird Database

string Query = "UPDATE FILEMASTER SET FILECONTENT=@BLOBData WHERE FILECODE=" + FileCode;


Above is my query.

below is the Code for saving Database into database

FbConnection fbconnection = new FbConnection();
try
{
fbconnection.ConnectionString = Connectionstring;
fbconnection.Open();

FbCommand fbcommand = new FbCommand(Query, fbconnection);
fbcommand.Parameters.Add("@Content", FbDbType.Text).Value = FileContent.Trim().Replace("'", "''");
fbcommand.ExecuteNonQuery();
}
catch
{
}
finally
{
fbconnection.Close();
}



i have used update query for this, you can use insert query for saving new entry.

for the table fields to store image data the datatype for this has to set for BLOB.

Storing of BLOB Data depends on the subtype. BLOB data are of unlimited size.
if you want to store plain text in the Field you can user SUBTYPE as 1

and if you want to store files, you can use SUBTYPE as 0.