problem access insert instruction

D

dinosors

i don't know what to do really i've seen the code 100 times and it seem right
so if anyone can help....this's the code

public void ajout_dossier_image(string dossier,string matr)
{

if (Directory.Exists(dossier))
{ try
{
scanDirectory(dossier, "*.jpg", System.IO.SearchOption.
TopDirectoryOnly);
String selectedImage = selectedImg;
if (imgList == null)
return;
foreach (String img in imgList) {ajout_image_seul(img,
matr);}
}
catch (Exception exe) { MessageBox.Show("erreur du dossier de
l'image");}
}
}
public void ajout_image_seul(string nom_img,string matr)
{
try
{
string date = "01/01/2005";//Convert.ToString(DateTime.Now)
string conStr = @"Provider=Microsoft.JET.OLEDB.4.0;" + @"data
source=DermatoSoft_DB.mdb";
dataGridView1.DataSource = null;
ds = new DataSet();
conn = new OleDbConnection(conStr);
command = conn.CreateCommand();
conn.Open();
command.CommandText = "INSERT INTO Image (Numero_Patients,
Nom_Image,Date_Image,"
+"Commentaire_Image) VALUES (" + matr + ",'" + nom_img +
"','" + date + "','exemple commentaire')";
adapter = new OleDbDataAdapter(command);
adapter.Fill(ds);
conn.Close();
}
catch (Exception exe)
{
MessageBox.Show("erreur dans l'ajout de l'image");
}
}

thanks
 
E

eusebiu

Try this :
public void ajout_image_seul(string nom_img,string matr)
{
try
{
string date = "01/01/2005";//
Convert.ToString(DateTime.Now)
string conStr = @"Provider=Microsoft.JET.OLEDB.4.0;" +
@"data
source=DermatoSoft_DB.mdb";
dataGridView1.DataSource = null;
ds = new DataSet();
conn = new OleDbConnection(conStr);
command.Connection = conn;

command.CommandText = "INSERT INTO Image
(Numero_Patients,
Nom_Image,Date_Image,"
+"Commentaire_Image) VALUES (" + matr + ",'" +
nom_img +
"','" + date + "','exemple commentaire')";
conn.Open();
int rowsAffected = command.ExecuteNonQuery();//must be
1
conn.Close();
}
catch (Exception exe)
{
MessageBox.Show("erreur dans l'ajout de l'image");
}
}
 
Top