| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 736 人关注过本帖
标题:Visual Basic数据库开发疑难问题解
只看楼主 加入收藏
jasonbaowm
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-4-25
收藏
 问题点数:0 回复次数:1 
Visual Basic数据库开发疑难问题解


问:如何显示格式为03-3-13的日期?

解决的c.com" class="wordstyle">方法:

1

Cmd.CommandText = "select * from 支出 where 日期=03-3-13" 中 03-3-13=-13。

日期实际上是Double型数字。0 是 1899-12-30,-13 是 1899-12-17。你当然没有这样日期的记录,所以只有大于才行。

2

Cmd.CommandText = "select * from 支出 where 日期=#03-3-13#"

凡是没有明示,文字型日期是按美国习惯解释的,#03-3-13# 是 0013-03-03。

或者使用长日期格式:

Cmd.CommandText = "select * from 支出 where 日期=#2003-3-13#"

用格式化函数

Cmd.CommandText = "select * from 支出 where 日期=#" & format(mydate,"yyyy-mm-dd") & "#"

问: 如何判断DNS是否存在?怎样才能列举出所有的DNS?

解决c.com" class="wordstyle">方法:

1、通过利用ODBC API中的c.com" class="wordstyle">SQLDataSource函数可以取得ODBC API中数据源的列表。 判断DNS是否存在:

2、使用API函数Private Declare Function c.com" class="wordstyle">SQLDataSources Lib "ODBC32.DLL" (ByVal henv As Long, ByVal fDirection As Integer, ByVal szDSN As String, ByVal cbDSNMax As Integer, pcbDSN As Integer, ByVal szDescription As String, ByVal cbDescriptionMax As Integer, pcbDescription As Integer) As Integer Private Declare Function c.com" class="wordstyle">SQLAllocEnv Lib "ODBC32.DLL" (ByRef env As Long) As Long 列举出所有DNS。

问:处理文本文件是导入c.com" class="wordstyle">数据库还是直接读写文件呢?

解决c.com" class="wordstyle">方法:

class=code>Set main = bumony.OpenRecordset("main")
Open App.Path & "\sources\" & Text1.Text & "\′úàíòμ??" & Text1.Text & ".txt" For Input As #1
Do While Not EOF(1)
Line Input #1, str1
With main
.AddNew
!code = Mid(str1, 1, 5)
!date = Text1.Text
If Mid(str1, 1, 5) = "21310" Or Mid(str1, 1, 5) = "21311" Or Mid(str1, 1, 5) = "21410" Or Mid(str1, 1, 5) = "21411" Then
!Money = Trim(Mid(str1, 7, 10))
Else
!Money = Trim(Mid(str1, 7, 10)) & "0000"
End If
!whao = "1102"
!ywhao = "1102"
.Update
End With
Loop
Close #1
main.Close

问:调用c.com" class="wordstyle">SQL存储后有参数返回,应该怎么赋值?

解决c.com" class="wordstyle">方法:

class=code>Dim ADOCmd As New ADODB.Command
Dim ADOPrm As New ADODB.Parameter
Dim ADORs As ADODB.Recordset
'....
Set ADOCmd.ActiveConnection = ADOCon
With ADOCmd
.CommandType = adCmdStoredProc
.CommandText = "ADOTestRPE"
End With
sParmName = "Output"
Set ADOPrm = ADOCmd.CreateParameter(sParmName, adInteger, adParamOutput)
ADOCmd.Parameters.Append ADOPrm
ADOCmd.Parameters(sParmName).Value = 999
Set ADORs = ADOCmd.Execute
'.....
Debug.Print "Output: " & ADOCmd.Parameters("Output").Value

· 巧用Win32 API函数增强VB位操作功能 05-11 18
· Visual Basic数据库开发疑难问题解 05-11 19
· Visaul C++6.0中使用串行通信控件 05-11 17
· 使用Data控件访问数据库 05-11 17

搜索更多相关主题的帖子: 数据库 Basic Visual 疑难 开发 
2007-05-24 10:07
jasonbaowm
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-4-25
收藏
得分:0 
回复:(jasonbaowm)Visual Basic数据库开发疑难问题...
· WebComputing━ADO总结报告 05-11 17
· [图文] VB表格控件总览与例程分析 05-11 19
· Visual Basic通用报表设计小结 05-11 17
· 在Access数据库中实现密码管理 05-11 16
· VB6.0数据库访问技术与例程解析 05-11 17
· VB6中用DataReport做报表
2007-05-25 12:02
快速回复:Visual Basic数据库开发疑难问题解
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015275 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved