引用
Public Module SQL Private ConnStr as string = "........." Public Function RunSQL(Byval SQL As String) As Integer Using Conn As new SqlConnection(ConnStr) Using Cmd = Conn.CreateCommand() Conn.Open() Cmd.CommandText = SQL Try Return Cmd.ExecuteNonQuery Catch ex as Exception '.....錯誤處理.... Finally Conn.Close() End Catch End Using End Using Edn Function 'Public Function CreateTable(byval SQL as string) as DataTable 'Public Function CreateDataReader(byval SQL as string) as SqlDataReader End Module '==外部呼叫=== SQL.RunSQL("Update MyTB Set A= '2'") '一行....
Private Sub 讀取程序(ByVal vSQL As String, Optional ByVal v資料表名稱 As String = Nothing) If v資料表名稱 = Nothing Then Dim v分割() As String = vSQL.Split(" ") v資料表名稱 = v分割(Array.IndexOf(v分割, "from") + 1) ' 識別資料表名稱 End If If IsNothing(資料集.Tables(v資料表名稱)) = False Then 資料集.Tables(v資料表名稱).Clear() 資料表配接器.SelectCommand = New OleDb.OleDbCommand(vSQL, SQL連線) 資料表配接器.Fill(資料集, v資料表名稱) End Sub
'===========================================================
Private Sub 列印_PrintPage(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles 列印.PrintPage Dim v總資料() As String = v列印字串.Split(New String() {vbNewLine}, StringSplitOptions.None) ' 分割字串 While v列印行數 < v一頁行數 * v頁數 And v列印行數 < v總資料.Length e.Graphics.DrawString(v總資料(v列印行數), v列印字型, Brushes.Black, 100, vY) vY += v列印字型.Height v列印行數 += 1 End While If v列印行數 = v一頁行數 * v頁數 And v列印行數 < v總資料.Length Then e.HasMorePages = True vY = 0 : v頁數 += 1 Else e.HasMorePages = False End If End Sub
沒有留言:
張貼留言