I am trying this to make a select and it works just fine
string str =
"SELECT * FROM FREE RIGHT JOIN TestTest ON FREE.DOCNO = TestTest.DOCNO";
DataTable dt = new DataTable();
OdbcDataAdapter da = new OdbcDataAdapter(str, odbconn);
da.Fill(dt);
I am trying this to create a .dbf and i get this OdbcException :
string str0 = "Create Table Persons (Name char(50), City char(50), Phone char(20), Zip decimal(5))";
OdbcCommand cmd = new OdbcCommand(str0, odbconn);
cmd.ExecuteNonQuery();
ERROR [42000] [Microsoft][ODBC dBase Driver] Syntax error in field definition.
Use vfpoledb provider and field type
NUMERIC
instead ofDECIMAL
.Your problem is caused by
Zip decimal(5)
, as the ODBC dBase driver doesn't like it. Off the top of my head, and after a quick google, I couldn't come up with a syntax it would tolerate. It does accept it quite merrily if you use the OleDb provider instead, as follows:One question though: Are you sure that you want to create the Zip column as a decimal? Not being a US resident I'm not 100% confident on this information, but, according to Wikipedia ZIP codes can start with a
0
. Storing them as a numeric datatype won't allow you to accurately represent that.My code for creating the table via ODBC: