I Try to save a File in DB.
I get the File from OpenFileDialog and save it in a Stream.
This stream i Read to a String and try to save it in a MySQL DB.
It Woks with smole .txt Files.
But not with .jpg. (to big string?)
I get ERROR: "MySql.Data.MySqlClient.MySqlException" in MySql.Data.dll
public void UplodeFile(int user, Stream filestream)
{
StreamReader streamReader = new StreamReader(filestream);
string filestring = streamReader.ReadToEnd();
string query = "INSERT INTO datein Values " +
"(NULL,'" + user + " ','" + filestring +"');";
MySqlCommand commandDatabase = new MySqlCommand(query, databaseConaction);
commandDatabase.CommandTimeout = 60;
try
{
databaseConaction.Open();
MySqlDataReader reader = commandDatabase.ExecuteReader();
databaseConaction.Close();
}
catch (Exception e)
{
Console.Write("error: " + e.Message);
}
}
I Use in db datatype LONGBLOB.
I have try binary it dosen't work