vb 连接数据例子
'工程-->引用 添加 Microsoft activex data objects 2.5 library
'工程-->部件 添加 Microsoft flexgrid control 6.0
Dim Cnn As New ADODB.Connection
Cnn.ConnectionString = "Provider=microsoft.jet.oledb.4.0;data source=E:\Access DB\Database1.mdb;"
If Cnn.State <> ADODB.ObjectStateEnum.adStateClosed Then Cnn.Close
Cnn.Open
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
With Rs
Set .ActiveConnection = Cnn
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "SELECT good_code,customer,sum(price*amount)/sum(amount) AS avg_price from sales GROUP BY good_code,customer"
If .RecordCount > 0 Then
MSFlexGrid1.Clear
MSFlexGrid1.Cols = 3
MSFlexGrid1.Rows = .RecordCount + 1
MSFlexGrid1.TextMatrix(0, 0) = "商品编号"
MSFlexGrid1.TextMatrix(0, 1) = "顾客名称"
MSFlexGrid1.TextMatrix(0, 2) = "平均价格"
.MoveLast: .MoveFirst
For i = 1 To .RecordCount
MSFlexGrid1.TextMatrix(i, 0)
相关文档:
'这里是启动过程[事件互斥就不写了]
Dim f as frmMain
Sub Main
Set f=New frmMain
f.Show
End Sub
'这里是一个线程类。。。随便写啥。。。
类名:BT
'这里是主窗口
Dim cBT as BT
Sub form_Load
'奇怪的问题就在这里...
Set cBT=CreateObject("工程名.BT")
'在L ......
SQLDMO在VB中的应用
http://blog.csdn.net/cncco/archive/2010/03/09/5362111.aspx
SQLDMO(SQL Distributed Management Objects,SQL分布式管理对象)封装 Microsoft SQL Server 2000 数据库中的对象。SQL-DMO 允许用支持自动化或 COM 的语言编写应用程序,以管理 SQL Server 安装的所有部分。 SQL-DMO 是 SQL Server 20 ......
做个mp3播放器,用realplay和WMP做出来的程序内存占用太大。
如果你仅仅是播放MP3,建议使用API函数mciSendString。
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal
lpstrReturnString As String, ByVal uReturnLength As Lo ......
1. 在VB的Form设计时,加入一个picturebox控件,这个控件作为OLE容器,MapInfo中的地图将在该控件上显示。
2. 执行VB的函数Createobject(“MapInfo.Application”),启动MapInfo。这时MapInfo在后台启动,对用户来说不可见,不会弹出sp ......
Dim strPath As String = Server.MapPath("~\文件夹")
'判断保存文件路径是否存在 不存在则创建
If Not Directory.Exists(strPath) Then
Directory ......