2013-02-18 57 views
0

嘿,我需要這個任務幫助,請我有一個MDB數據庫,一個表名爲名爲課程與Course1 4場如何在提交按鈕時將兩個單選按鈕和一個總數添加到mdb數據庫?

ID(AutoNumber),Alchamex1(Text) and Alchamex2(Text) Total(Text) 

我怎麼事先有這些選擇的值到一個MDB數據庫,謝謝!

If CheckBox1.Checked = True And CheckBox2.Checked = True Then 
    answerLbl.Text =(Double.Parse(Label1.Text)+ Double.Parse(Label2.Text)).ToString() 
ElseIf CheckBox2.Checked = True Then 
    answerLbl.Text =Label2.Text 
ElseIf CheckBox1.Checked = True Then 
    answerLbl.Text = Label1.Text 
End If 

回答

1

基本步驟:

OleDbConnection connection = new OleDbConnection (connectionString); 
OleDbCommand cmd = new OleDbCommand(); 
cmd.Connection = connection; 
cmd.CommandText= "INSERT INTO Table1(col1, col2) VALUES (@col1, @col2)"; 
cmd.Parameters.Add ("@col1", OleDbType.String).Value = valueToInsert; 
... 
cmd.ExecuteNonQUery(); 

參見本:

Inserting Records into a Microsoft Access Database with ASP.NET

Connecting asp.net with MS access 2007 in VS 2010

INSERT from ASP.NET to MS Access

相關問題