VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - Access数据库中无效的字符字段的行为
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:12674, 日期:2001-04-12
Dealing with Null strings in Access database fields

By default Access string fields contain NULL values unless a string value (including a blank string like "") has been assigned. When you read these fields using recordsets into VB string variables, you get a runtime type-mismatch error. The best way to deal with this problem is to use the built-in & operator to concatenate a blank string to each field as you read it. For example:

Dim DB As Database
Dim RS As Recordset
Dim sYear As String
Set DB = OpenDatabase("Biblio.mdb")
Set RS = DB.OpenRecordset("Authors")
sYear = "" & RS![Year Born]