SqlExeception non compris
J'essais de remplir une base de données à partir d'infos d'un fichier texte
voici le code C# utilisé :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// ouverture connection
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" +
"C:\\Program Files\\Microsoft SQL Server\\MSSQL.2\\MSSQL\\Data\\SITEWEBGLOBAL.mdf" +
";Integrated Security=True;Connect Timeout=30;User Instance=True";
myConnection.Open();
string ligne = "";
string[] ligneSplit;
string numpage = "";
string titre = "";
string texte = "";
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;
StreamReader fichier = new StreamReader("C:\\Documents and Settings\\Administrateur\\Bureau\\tablepage.txt");
while (!fichier.EndOfStream){
ligne = fichier.ReadLine();
ligneSplit = ligne.Split(Encoding.ASCII.GetChars(new byte[]{9}));
numpage = ligneSplit[0];
titre = ligneSplit[1];
texte = ligneSplit[2];
myCommand.CommandText = "INSERT INTO PAGE (NUM_PAGE,TITRE_PAGE,TEXTE_PAGE) VALUES ('"+numpage +"','"+titre+"','"+texte+"');";
myCommand.ExecuteNonQuery();
}
fichier.Close();
myConnection.Close();
MessageBox.Show("fin intégration"); |
Quand je suis à la ligne
Code:
myCommand.ExecuteNonQuery();
,
j'obtiens un SQlExecption qui me dit ;"Syntaxe incorrecte vers 'externalisation' "
Donc je n'y comprend strictement rien
pouvez vous m'aider sur ce point ?