Marie-Christine Bechara said:
I have a form with a button called btnScan. When i click on this button
i want to scan a file and save it in the database. Any hints?? ideas???
solutions???
Hi,
Hi,
What I did was the following:
(Inside the Eventhandler for the button click!)
Open the file - Parse the lines - Close the File - Generate SQL
statement - Execute the statement
Example:
MySQLString sql = new MySQLString();
StreamReader sr = new
StreamReader(tmp.DIOFile,System.Text.Encoding.Default);
string actLine;
while( (actLine = sr.ReadLine()) != null )
{
#region Process the Data Here
sql.SQLCommand = "INSERT INTO DBTBL.name VALUES ('"+actLine+"')";
#endregion
}
sr.Close();
#region PROCESS ODBC STUFF HERE
if(ODBCConnection.State != ConnectionState.Open)
ODBCConnection.Open();
OdbcCommand comm = new OdbcCommand(sql.SQLCommand, ODBCConnection);
try
{
comm.ExecuteNonQuery();
comm.Dispose();
}
catch(OdbcException ex)
{
MessageBox.Show(ex.Errors[0].Message);
ODBCConnection.Close();
return;
}
ODBCConnection.Close();
#endregion
Hope this is what you are looking for,
Martin