當前位置:首頁 » 數據倉庫 » vbnet資料庫編程pdf
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

vbnet資料庫編程pdf

發布時間: 2023-02-07 23:39:50

① vb.net 導出PDF

利用DataWindow.net在 vb.net 下導出PDF格式文件
利用datawindow.net,導出PDF文件,實現前提:
1.安裝Acrobat Distiller虛擬列印機,注意要用datawindow.net提供的列印驅動,在c:\program files\sybase\datawindow.net2.0\driver中,在文章最後,我會提供一個靜態安裝虛擬列印機的批處理文件,方便安裝。
2.安裝Ghostscript 7.05 ,在網上找,免費的。
3.導出PDF文件前,一要指定虛擬列印機名,其次導出格式為PDF(Export.PDF.Method=Distill!),另外還要指定 PDF.Distill.CustomPostScript=Yes。
具體代碼如下:
''' <summary>
''' 導出文件
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
Try
Dim strFilename, strPrinter As String
Dim saveDg As New SaveFileDialog
strPrinter = Me.dwPrint.Describe("DataWindow.Print.PrinterName")
saveDg.FileName = Me.dwPrint.Tag.ToString
saveDg.Filter = "Pdf文件|*.pdf|Excel文件|*.xls|所有文件|*.*"
If saveDg.ShowDialog = Windows.Forms.DialogResult.OK Then
strFilename = saveDg.FileName
If strFilename.IndexOf(".pdf") > 0 Then
Me.dwPrint.Modify("DataWindow.Print.PrinterName='Acrobat Distiller'")
Me.dwPrint.Modify("DataWindow.Export.PDF.Method=Distill!")
Me.dwPrint.Modify("DataWindow.Export.PDF.Distill.CustomPostScript=Yes")
Me.dwPrint.SaveAs(strFilename, Sybase.DataWindow.FileSaveAsType.Pdf, True)
ElseIf strFilename.IndexOf(".xls") > 0 Then
Me.dwPrint.SaveAs(strFilename, Sybase.DataWindow.FileSaveAsType.Excel, True)
End If
Me.dwPrint.Modify("DataWindow.Print.PrinterName='" + strPrinter + "'")
MessageBox.Show("導出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

4 批處理文件(實現靜默安裝)

② Vb.net 如何向access資料庫的附件列進行讀寫附件,比如PDF文件

可以使用OLE 去添加和下載附件

③ VB如何把Word/PDF等一般文件寫入資料庫

用過Stream變數,不過只寫過圖片--一樣的,換下文件名即可

④ vb.NET 關於資料庫的讀寫 - 高分

Dim da As New OleDb.OleDbDataAdapter(『』輸入2/3/4其中的答案)
Dim ds As New DataSet
da.Fill(ds, "Table1")
Dim dt As DataTable
dt = ds.Tables("Table1")

//2. Cmd.CommandText = "select 序號 from 賬號 where 姓名='小李'"
//3. Cmd.CommandText = "select 序號 from 賬號 where 姓名='小張'"
//4. Cmd.CommandText = "insert into 賬號(姓名,年齡,性別,序號) values('張三','22','男','4')"

DataGridView1.DataSource = dt '建立datagridview來顯示資料
myCn.Close()

⑤ vb.net資料庫操作

參考一下下面這段代碼就可以了。

Imports System.Data
'引入資料庫操作類命名空間
Imports System.Data.OleDb
'引入ADO.NET操作命名空間
Public Class FrmModifystInfo
Inherits System.Windows.Forms.Form
Public ADOcmd As OleDbDataAdapter
Public ds As DataSet = New DataSet()
'建立DataSet對象
Public mytable As Data.DataTable
'建立表單對象
Public myrow As Data.DataRow
'建立數據行對象
Public rownumber As Integer
'定義一個整型變數來存放當前行數
Public Searchsql As String
Public cmd As OleDbCommandBuilder
'======================================================
#Region " Windows 窗體設計器生成的代碼 "

#End Region
'======================================================
Private Sub FrmModifystInfo_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'窗體的載入
TxtSID.Enabled = False
TxtName.Enabled = False
ComboSex.Enabled = False
TxtBornDate.Enabled = False
TxtClassno.Enabled = False
TxtRuDate.Enabled = False
TxtTel.Enabled = False
TxtAddress.Enabled = False
TxtComment.Enabled = False '設置信息為只讀
Dim tablename As String = "student_Info "
SearchSQL = "select * from student_Info "
ExecuteSQL(SearchSQL, tablename) '打開資料庫
ShowData() '顯示記錄
End Sub

Private Sub ShowData()
'在窗口中的textbox中顯示數據
myrow = mytable.Rows.Item(rownumber)
TxtSID.Text = myrow.Item(0).ToString
TxtName.Text = myrow.Item(1).ToString
ComboSex.Text = myrow.Item(2).ToString
TxtBornDate.Text = Format(myrow.Item(3), "yyyy-MM-dd ")
TxtClassno.Text = myrow.Item(4).ToString
TxtTel.Text = myrow.Item(5).ToString
TxtRuDate.Text = Format(CDate(myrow.Item(6)), "yyyy-MM-dd ")
TxtAddress.Text = myrow.Item(7).ToString
TxtComment.Text = myrow.Item(8).ToString
End Sub

Private Sub BtFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtFirst.Click
'指向第一條數據
rownumber = 0
ShowData()
End Sub

Private Sub BtPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtPrev.Click
'指向上一條數據
BtNext.Enabled = True
rownumber = rownumber - 1
If rownumber < 0 Then
rownumber = 0 '如果到達記錄的首部,行號設為零
BtPrev.Enabled = False
End If
ShowData()
End Sub

Private Sub BtNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtNext.Click
'指向上一條數據
BtPrev.Enabled = True
rownumber = rownumber + 1
If rownumber > mytable.Rows.Count - 1 Then
rownumber = mytable.Rows.Count - 1 '判斷是否到達最後一條數據
BtNext.Enabled = False
End If
ShowData()
End Sub

Private Sub BtLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtLast.Click
'指向最後一條數據
rownumber = mytable.Rows.Count - 1
ShowData()
End Sub

Private Sub BtDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtDelete.Click
mytable.Rows.Item(rownumber).Delete() '刪除記錄
If MsgBox( "確定要刪除改記錄嗎? ", MsgBoxStyle.OKCancel + vbExclamation, "警告 ") = MsgBoxResult.OK Then
cmd = New OleDbCommandBuilder(ADOcmd)
'使用自動生成的SQL語句
ADOcmd.Update(ds, "student_Info ")
BtNext.PerformClick()
End If
End Sub

Private Sub BtModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtModify.Click
TxtSID.Enabled = False '關鍵欄位只讀
TxtName.Enabled = True '可讀寫
ComboSex.Enabled = True
TxtBornDate.Enabled = True
TxtClassno.Enabled = True
TxtRuDate.Enabled = True
TxtTel.Enabled = True
TxtAddress.Enabled = True
TxtComment.Enabled = True
End Sub

Private Sub BtUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtUpdate.Click
If Not Testtxt(TxtName.Text) Then
MsgBox( "請輸入姓名! ", vbOKOnly + vbExclamation, "警告 ")
TxtName.Focus()
Exit Sub
End If
If Not Testtxt(ComboSex.Text) Then
MsgBox( "請選擇性別! ", vbOKOnly + vbExclamation, "警告 ")
ComboSex.Focus()
Exit Sub
End If
If Not Testtxt(TxtClassno.Text) Then
MsgBox( "請選擇班號! ", vbOKOnly + vbExclamation, "警告 ")
TxtClassno.Focus()
Exit Sub
End If

If Not Testtxt(TxtTel.Text) Then
MsgBox( "請輸入聯系電話! ", vbOKOnly + vbExclamation, "警告 ")
TxtTel.Focus()
Exit Sub
End If
If Not Testtxt(TxtAddress.Text) Then
MsgBox( "請輸入家庭住址! ", vbOKOnly + vbExclamation, "警告 ")
TxtAddress.Focus()
Exit Sub
End If
If Not IsNumeric(Trim(TxtSID.Text)) Then
MsgBox( "請輸入數字學號! ", vbOKOnly + vbExclamation, "警告 ")
Exit Sub
TxtSID.Focus()
End If
If Not IsDate(TxtBornDate.Text) Then
MsgBox( "出生時間應輸入日期格式(yyyy-mm-dd)! ", vbOKOnly + vbExclamation, "警告 ")
Exit Sub
TxtBornDate.Focus()
End If
If Not IsDate(TxtRuDate.Text) Then
MsgBox( "入校時間應輸入日期格式(yyyy-mm-dd)! ", vbOKOnly + vbExclamation, "警告 ")
TxtRuDate.Focus()
Exit Sub
End If
myrow.Item(0) = Trim(TxtSID.Text)
myrow.Item(1) = Trim(TxtName.Text)
myrow.Item(2) = Trim(ComboSex.Text)
myrow.Item(3) = Trim(TxtBornDate.Text)
myrow.Item(4) = Trim(TxtClassno.Text)
myrow.Item(5) = Trim(TxtTel.Text)
myrow.Item(6) = Trim(TxtRuDate.Text)
myrow.Item(7) = Trim(TxtAddress.Text)
myrow.Item(8) = Trim(TxtComment.Text)
mytable.GetChanges()
cmd = New OleDbCommandBuilder(ADOcmd)
'使用自動生成的SQL語句
ADOcmd.Update(ds, "student_Info ")
'對資料庫進行更新
MsgBox( "修改學籍信息成功! ", vbOKOnly + vbExclamation, "警告 ")
TxtName.Enabled = False
ComboSex.Enabled = False
TxtBornDate.Enabled = False
TxtClassno.Enabled = False
TxtRuDate.Enabled = False
TxtTel.Enabled = False
TxtAddress.Enabled = False
TxtComment.Enabled = False '重新設置信息為只讀
End Sub

Private Sub BtCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtCancel.Click
TxtSID.Enabled = False
TxtName.Enabled = False
ComboSex.Enabled = False
TxtBornDate.Enabled = False
TxtClassno.Enabled = False
TxtRuDate.Enabled = False
TxtTel.Enabled = False
TxtAddress.Enabled = False
TxtComment.Enabled = False
End Sub

Public Function ExecuteSQL(ByVal SQL As String, ByVal table As String)
Try
'建立ADODataSetCommand對象
'資料庫查詢函數
ADOcmd = New OleDbDataAdapter(SQL, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\student.mdb ")
'建立ADODataSetCommand對象
ADOcmd.Fill(ds, table) '取得表單
mytable = ds.Tables.Item(0) '取得名為table的表
rownumber = 0 '設置為第一行
myrow = mytable.Rows.Item(rownumber)
'取得第一行數據
Catch
MsgBox(Err.Description)
End Try
End Function
End Class

⑥ 誰有autocad vba & vb.net開發基礎與實例教程pdf版

【AutoCAD VBA視頻教程\cad二次開發\CAD VBA\自動發貨\自學利器】,復·制這段描述€dSze0wA8OIU€後到👉淘♂寳♀👈

⑦ 那裡有《VB.NET入門經典》電子書下載

剛好我也在找,我找到了一個,推薦!

1000本VB編程技術電子書專題下載:
http://download.chinaitlab.com/special/vbebook.htm

VB.NET學習教程(PDF):
http://www.yesadmin.com/Soft/html/34/233/yesadmin_39221.html

⑧ vb.net 寫資料庫

你這是向sql後台資料庫寫數據嗎?
sqldataadapter1.update 改須指定有效的updatecommand,我一直沒有看到
給你個例子你看吧:

'首先指定有效的UpdateCommand
sqlstr = "insert into Playlist(PlayName,PlayPath)values('" & TextBox4.Text.Trim & "','" & TextBox5.Text.Trim & "')"

Mole1.Mycommand.CommandText = sqlstr

'增加新一行(此行必須,要不不能與後台同步,並且後面調用update會出錯)
Mole1.MyDataSet.Tables("Music").Rows.Add()

Mole1.MyDataAdaPter.InsertCommand = Mole1.Mycommand
Mole1.MyDataAdaPter.Update(Mole1.MyDataSet, "Music")

MsgBox("增加數據成功!!")

⑨ vb.net如何將excel指定的sheet生成pdf 我裡面有sheet1~5,只想將sheeet2、3轉成PDF,並且轉完後打開預覽

你可以使用Spire.Xls來實現。Spire.Xls可以讓你方便地將excel中指定的sheet導出為pdf文件,並且支持在導出時指定sheet2和sheet3。同樣可以使用該框架來快速預覽生成的pdf文件。