-3

我总是在创建表语句中遇到错误。

try{
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

 Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/my project/apache-tomcat-7.0.41/odbcdsn name.mdb"
      );

 Statement st=conn.createStatement();

 st.executeUpdate("CREATE TABLE  appr (_name varchar(10),_fname varchar(10),gender varchar(1),cat varchar(10),emp varchar(3),pno integer(10),_cno integer(10),email varchar(30),address varchar(40), pno integer(6),boe varchar(6),tot integer(3),ttl integer(3))");

有人可以帮我解决这个问题吗?

4

1 回答 1

0

Well, the error message you get is pretty clear about what the problem is:

Msg 2716, Level 16, State 1, Line 1
Column, parameter, or variable #6: Cannot specify a column width on data type int.

So, try this:

CREATE TABLE dbo.appr (
   _name VARCHAR(10),
   _fname VARCHAR(10),
   gender VARCHAR(1),
   cat VARCHAR(10),
   emp VARCHAR(3),
   pno INTEGER,
   _cno INTEGER,
   email VARCHAR(30),
   address VARCHAR(40),
   ___pno INTEGER,
   boe VARCHAR(6),
   tot INTEGER,
   ttl INTEGER
  );

I just replaced INTEGER(?) with INTEGER. You need to figure out which datatype you really want. You can start here: http://msdn.microsoft.com/en-us/library/ms187752.aspx

There was also a duplicate column name in your table, interestingly enough using different datatypes... I replaced one of them with ___pno

于 2013-06-18T13:12:16.843 回答