当前位置:首页 » 数据仓库 » 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文件。