Home > Net >  The Access System. Data. The OleDb. OleDbException: "Data type does not match the standard expr
The Access System. Data. The OleDb. OleDbException: "Data type does not match the standard expr

Time:04-05

New record when encounter this problem, baidu + test 3 hours, concluded that the type of data in the datatable and access data type in c # does not match, and then change the code as follows, the result is the same mistake. All the data types has been updated. No popup window, the last step when an error: "standard data type does not match the expression," big help, according to my own ideas, in all the types, why or is it an error?
 public static void zengjiarucang DataRow (Dr) 
{
String zengjiacc="";
String zengjiaaa="";
Int PLD=DTCRC. Columns. The Count;
For (int I=0; i {
String. PLS=DTCRC Columns [I] Caption;
If (I==0)
{

Zengjiacc="[" + PLS +"] ".
Zengjiaaa="@" + PLS;
}
The else
{
Zengjiacc=zengjiacc + ", [" + PLS + "] ".
Zengjiaaa=zengjiaaa +, "@" + PLS;
}
}

String zengjia="insert into [transport] (" + zengjiacc +") values (" + zengjiaaa + ") ";
OleDbCommand comm=new OleDbCommand (zengjia, conn);
Zengjia="";
//System. Windows. Forms. MessageBox. Show (zengjia);
For (int I=0; i {
String. PLS=DTCRC Columns [I] Caption;

If (Dr [I]. GetType (). The FullName, Equals (" System. A DateTime "))
{
OleDbParameter parm=new OleDbParameter (" @ "+ PLS, OleDbType DBTimeStamp);


The parm. Value=https://bbs.csdn.net/topics/Convert.ToDateTime (Dr [I] the ToString ()). The ToString (" MM - dd yyyy - HH: MM: ss ");
Comm. The Parameters. The Add (parm);

}
The else
{

If (Dr [I]. GetType (). The FullName, Equals (" System. Int32))
{
OleDbParameter parm=new OleDbParameter (" @ "+ PLS, OleDbType. Integer);
The parm. Value=https://bbs.csdn.net/topics/Int32.Parse (Dr [I] the ToString ());
Comm. The Parameters. The Add (parm);

}
The else
{

If (Dr [I]. GetType (). The FullName, Equals (" System. The Double "))
{
OleDbParameter parm=new OleDbParameter (" @ "+ PLS, OleDbType. Double);
The parm. Value=https://bbs.csdn.net/topics/double.Parse (Dr [I] the ToString ());
Comm. The Parameters. The Add (parm);

}
The else
{

If (Dr [I]. GetType (). The FullName, Equals (" System. The String "))
{
OleDbParameter parm=new OleDbParameter (" @ "+ PLS, OleDbType VarWChar);
The parm. [I] Value=https://bbs.csdn.net/topics/dr. ToString ();
Comm. The Parameters. The Add (parm);

}
The else
{

System. Windows. Forms. MessageBox. Show (Dr [I] GetType (), ToString ());

}

}

}

}

}

Comm. ExecuteNonQuery ();
}



  •  Tags:  
  • C#
  • Related