大家看看下面语句错。。Dataset填充SQL表
string file = "~/uploadfiles/ " +DropDownList1.Text;
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0; " + " Data Source= " + Server.MapPath(file) + "; Extended Properties=Excel 8.0; ";
OleDbConnection Conn = new OleDbConnection(ConStr);
Conn.Open();
OleDbCommand Comm = new OleDbCommand( "select * from [Sheet1$] ", Conn);
OleDbDataAdapter ad = new OleDbDataAdapter();
ad.SelectCommand = Comm;
DataSet ds = new DataSet();
ad.Fill(ds, "xls ");
OleDbCommandBuilder cb = new OleDbCommandBuilder(ad);
ad.Update(ds, "xls ");
GridView1.DataSource = ds;
GridView1.DataBind();
//以上都是正确的
string connstr = System.Configuration.ConfigurationSettings.AppSettings[ "connstring "];
SqlConnection con = new SqlConnection(connstr);
con.Open();
string strcom1 = "create table ' "+DropDownList1.Text+ " ' ";
SqlCommand mycom1=new SqlCommand(strcom1,con);
mycom1.ExecuteNonQuery();
Response.Write( " <script> alert( '新建了一个表! ');location= 'javascript:history.go(-1) ' </script> ");
for(int i=0;i < ds.Table[0].Rows.Count;i++)
{
string str=ds.Table[0].Rows[i][1].ToString();
string sqlstr= "insert into book values ( ' "+str+ " ') ";
SqlCommand com2 = new SqlCommands(sqlstr, con);
com2.ExecuteNonQuery();
&nb