บันทึกข้อมูลจาก RadioButtonList ใครช่วยบอกวิธีบันทึกข้อมูลจากRadioButtonList ลงDataBase ที่ครับช่วยบอกแบบละเอียดที่ครับ
ใช้การ insert ตามปกติครับ โดยใช้ Me.RadioButtonList1.SelectedItem.Text ในการอ่านค่าครับ
Code
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
End Sub
Sub btnSave_Click(sender As Object, e As EventArgs)
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim strConnString,strSQL As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";Jet OLEDB:Database Password=;"
strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " & _
" VALUES " & _
" ('" & Me.RadioButtonList1.SelectedItem.Text & "','" & Me.txtName.Text & "','" & Me.txtEmail.Text & "', " & _
" '" & Me.txtCountryCode.Text & "','" & Me.txtBudget.Text & "','" & Me.txtUsed.Text & "')"
objConn.ConnectionString = strConnString
objConn.Open()
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
Me.pnlAdd.Visible = False
Try
objCmd.ExecuteNonQuery()
Me.lblStatus.Text = "Record Inserted"
Me.lblStatus.Visible = True
Catch ex As Exception
Me.lblStatus.Visible = True
Me.lblStatus.Text = "Record can not insert Error ("& ex.Message &")"
End Try
objConn.Close()
objConn = Nothing
End Sub
</script>
Ref : ASP.NET Microsoft Access Add/Insert Record
Date :
2009-04-20 21:59:55
By :
webmaster
Load balance : Server 00