2012-03-22 13 views
-2

私はAccessデータベースに情報を挿入するためにC#でプログラムを書いています。だから、次のC#ステートメントとそれに続くフォームを使って、私のAccessフィールドがどんなデータ型であるかを知る必要があります。 (すなわち、{0} = int型、{1} = NCHAR) 私はそれがC#がAccess DBに結果 - "追加情報:条件式のデータ型が一致しません。"

![string vsql = string.Format("insert into Log values " + 
     "('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", 
     comboBox1.Text,     //(type?) 
     comboBox2.Text,     //(type?) 
     int.Parse(textBox1.Text),  //I want this to be float (possible?) 
     int.Parse(textBox1.Text),  //I want this to be float (possible?) 
     textBox2.Text,     //(type?) 
     textBox3.Text,     //(type?) 
     addRemove);      //(type?) 

enter image description here

答えて

1
string vsql = string.Format("insert into Log values " + 
     "('{0}','{1}',{2},{3},'{4}',#{5}#,'{6}')", 
     comboBox1.Text,   //string field 
     comboBox2.Text,   //string field 
     int.Parse(textBox1.Text), //don't wrap this in quotes if you want it as a float 
     int.Parse(textBox1.Text), //same as above 
     textBox2.Text,   //this is a DateTime field - you probably need to wrap with # marks. 
     textBox3.Text,   //string field 
     addRemove     //bool field 
     );  
+0

ありがとう、考え出し得るまで、私は、と思います!それは魅力のように働いた! – Geo

関連する問題