我在ALTER TABLE等方面遇到语法错误请提前帮助谢谢:) Visual Basic
Dim cnn As New OleDb.OleDbConnection
cnn = New OleDb.OleDbConnection
cnn.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Users\Ashe\Documents\Visual Studio 2010\Projects\WindowsApplication1\Guidance System.accdb")
Dim mydate As DateTime
mydate = Me.DateTimePicker1.Value
Dim AddCol = "ALTER TABLE Attendance " & _
"ADD '" & mydate & "');"
Using cmd = New OleDbCommand(AddCol, cnn)
cnn.Open()
cmd.ExecuteNonQuery()
End Using
答案 0 :(得分:0)
您尚未关闭字符串
{"location":"Web","initial":"","firmType":"","toaxfrtype":""}
注意:在发布最后一条评论后添加了Dim cnn As New OleDb.OleDbConnection
cnn = New OleDb.OleDbConnection
cnn.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Users\Ashe\Documents\Visual Studio 2010\Projects\WindowsApplication1\Guidance System.accdb")
Dim mydate As DateTime
mydate = Me.DateTimePicker1.Value
Dim AddCol = "ALTER TABLE Attendance " & _
"ADD '" & mydate & "' varchar(100);"
Using cmd = New OleDbCommand(AddCol, cnn)
cnn.Open()
cmd.ExecuteNonQuery()
End Using
,以便在此处获得有效的代码。
答案 1 :(得分:0)
我想出了这个代码,它现在正在运行。谢谢你们! :)
if ($this->request->is('post')) {
$a = $_POST['category'];
$b = $_POST['subcategory'];
$c = $_POST['category1'];
$d = $_POST['subcategory1'];
// i have checked whether values are comming to controller r not
echo $a;
echo $b;
echo $c;
echo $d;
//They are comming
// I have category and subcategory columns in my databse
// I want to store $a and $b in one row ,$c and $d values in the next row of my database .
// I have written like this
$this->Bill->create();
if ($this->Bill->save($this->request->data)) {
$this->Bill->saveField('category',$a);
$this->Bill->saveField('subcategory',$b);
$this->Bill->saveField('category',$c);
$this->Bill->saveField('subcategory',$d);
$this->Session->setFlash(__('The Bill has been saved'));
return $this->redirect(array('controller' => 'Bills','action' => 'view'));
}
$this->Session->setFlash(__('The bill could not be saved'));*/
}
// but $c and $d values are only storing in row.