Imports System.Data Imports System.Data.OleDb Partial Class Guo5 Inherits System.Web.UI.Page Shared tk_provider As String Shared tk_database As String Shared tk_conn As OleDbConnection Shared tk_sql As String Shared tk_cmd As OleDbCommand Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then Label1.Text = Session("桌號") tk_provider = "Provider=Microsoft.ACE.OLEDB.12.0" tk_database = "Data Source=" & Server.MapPath("點菜.accdb") tk_conn = New OleDbConnection(tk_provider & ";" & tk_database) tk_conn.Open() If CInt(Session("M001")) > 0 Then InsertData(Session("桌號"), "001", Session("M001")) End If If CInt(Session("M002")) > 0 Then InsertData(Session("桌號"), "002", Session("M002")) End If If CInt(Session("M003")) > 0 Then InsertData(Session("桌號"), "003", Session("M003")) End If If CInt(Session("M004")) > 0 Then InsertData(Session("桌號"), "004", Session("M004")) End If If CInt(Session("M005")) > 0 Then InsertData(Session("桌號"), "005", Session("M005")) End If If CInt(Session("M006")) > 0 Then InsertData(Session("桌號"), "006", Session("M006")) End If If CInt(Session("M007")) > 0 Then InsertData(Session("桌號"), "007", Session("M007")) End If If CInt(Session("M008")) > 0 Then InsertData(Session("桌號"), "008", Session("M008")) End If If CInt(Session("M009")) > 0 Then InsertData(Session("桌號"), "009", Session("M009")) End If If CInt(Session("M010")) > 0 Then InsertData(Session("桌號"), "010", Session("M010")) End If If CInt(Session("M011")) > 0 Then InsertData(Session("桌號"), "011", Session("M011")) End If If CInt(Session("M012")) > 0 Then InsertData(Session("桌號"), "012", Session("M012")) End If If CInt(Session("M013")) > 0 Then InsertData(Session("桌號"), "013", Session("M013")) End If If CInt(Session("M014")) > 0 Then InsertData(Session("桌號"), "014", Session("M014")) End If If CInt(Session("M015")) > 0 Then InsertData(Session("桌號"), "015", Session("M015")) End If If CInt(Session("M019")) > 0 Then InsertData(Session("桌號"), "019", Session("M019")) End If tk_conn.Close() End If End Sub Sub InsertData(ByVal TableNo As Integer, ByVal MeatNo As String, ByVal Num As Integer) tk_sql = "Insert Into 點餐資料表 (桌號,菜編號,數量) Values (" & TableNo & ",'" & MeatNo & "'," & Num & ")" tk_cmd = New OleDbCommand(tk_sql, tk_conn) tk_cmd.ExecuteNonQuery() If Err.Number = 0 Then Else Response.Write(Err.Description) End If End Sub End Class