双查询的问题

问题描述 投票:-3回答:1

我试图在一个按钮点击执行2查​​询..它似乎不起作用,只是自动关闭。任何人都可以帮助我或向我解释为什么我的代码不起作用?这是代码:

test = 1;
{
    connection.Open();
    string strTemp = " [StudentNum] Text, [StudentName] Text, [Section] Text, [TimeIn] Text, [TimeOut] Text, [Status] Text";
    OleDbCommand myCommand = new OleDbCommand();
    myCommand.Connection = connection;
    myCommand.CommandText = "CREATE TABLE [" + date + "](" + strTemp + ")";
    myCommand.ExecuteNonQuery();
    if (test == 1)
    {
        OleDbCommand commandl = new OleDbCommand();
        commandl.Connection = connection;
        commandl.CommandText = "INSERT INTO ['" + date + "']([StudentNum],[StudentName],[Section]) select [StudentNo],[Name],[Section] from StudInfo";
        commandl.ExecuteNonQuery();
    }
c# ms-access
1个回答
0
投票

删除撇号分隔表名称。

commandl.CommandText = "INSERT INTO [" + date + "]([StudentNum],[StudentName],[Section]) select [StudentNo],[Name],[Section] from StudInfo";

© www.soinside.com 2019 - 2024. All rights reserved.