Dim rst As New ADODB.RecordsetPrivate Sub Command1_Click()
rst.AddNew
rst.Update
rst.MoveLast
If IsNull(rst.Fields("Name")) = True Then
MsgBox "null"
Else
MsgBox "notnull"
End If
End SubPrivate Sub Form_Load()
Dim t As Variant
rst.Fields.Append "Name", adVarChar, 30
rst.Open
rst.AddNew
rst.Fields("Name") = "1"
rst.Update
End SubMSDN明明说不指定默认值的话,新增的会是Null,但是确不行.还有,我新增的字段的默认值也不行,提示参数出错.
rst.AddNew
rst.Update
rst.MoveLast
If IsNull(rst.Fields("Name")) = True Then
MsgBox "null"
Else
MsgBox "notnull"
End If
End SubPrivate Sub Form_Load()
Dim t As Variant
rst.Fields.Append "Name", adVarChar, 30
rst.Open
rst.AddNew
rst.Fields("Name") = "1"
rst.Update
End SubMSDN明明说不指定默认值的话,新增的会是Null,但是确不行.还有,我新增的字段的默认值也不行,提示参数出错.
解决方案 »
- 一个小问题,关于DataGrid的滚动条
- 干VB很多年了,但现在因工作需要,转向Delphi,各位给点建议,谢谢!
- 菜鸟问题,还望高手解答
- vb中怎么建立临时表 求助
- 请高手赐教~~~~~~~~~!
- WIN2000上开发的含SQL数据库的VB程序移植问题,在局域网中不可用,各位进来帮我看看
- vb从网站下载文件,如何获得真实文件名?比如某链接为:ab.ab.ab/llfjlfweo2elr 这个链接指向网站ab.ab.ab的一个文件
- 如何用VB制作象WINDOWS一样的帮助文件
- 在VB用winsock控件数组做winsock服务器比在VC++中用多线程做winsock服务器有什么缺点?
- 如何才能让所有表单都通过一个公用函数退出啊?主要是Unload 的参数不知怎么弄
- VB中如何用ADO访问FoxPro的DBF文件
- vs2005正式版下载
Appends an object to a collection. If the collection is Fields, a new Field object may be created before it is appended to the collection.Syntax
collection.Append object
fields.Append Name, Type, DefinedSize, Attrib, FieldValue
Parameters
collection
A collection object.
fields
A Fields collection.
object
An object variable that represents the object to be appended.
Name
A String value that contains the name of the new Field object, and must not be the same name as any other object in fields.
Type
A DataTypeEnum value, whose default value is adEmpty, that specifies the data type of the new field. The following data types are not supported by ADO, and should not be used when appending new fields to a Recordset: adIDispatch, adIUnknown, adVariant.
DefinedSize
Optional. A Long value that represents the defined size, in characters or bytes, of the new field. The default value for this parameter is derived from Type. Fields with a DefinedSize greater than 255 bytes, and treated as variable length columns. (The default DefinedSize is unspecified.)
Attrib
Optional. A FieldAttributeEnum value, whose default value is adFldDefault, that specifies attributes for the new field. If this value is not specified, the field will contain attributes derived from Type.
FieldValue
Optional. A Variant that represents the value for the new field. If not specified, then the field is appended with a null value. MSDN原文================业精于勤荒于嬉,形成于思毁于随=================如果再给我一次爱的机会,我会好好的珍惜!
我用vbEmpty这个常数判断是可以的了.vbEmpty 0 未初始化(缺省值) ================业精于勤荒于嬉,形成于思毁于随=================如果再给我一次爱的机会,我会好好的珍惜!
View or change the data in the field with the Value property. Value is the default property of the Field object.
Return the basic characteristics of a field with the Type, Precision, and NumericScale properties.
Return the declared size of a field with the DefinedSize property.
Return the actual size of the data in a given field with the ActualSize property.
Determine what types of functionality are supported for a given field with the Attributes property and Properties collection.
Manipulate the values of fields containing long binary or long character data with the AppendChunk and GetChunk methods.
If the provider supports batch updates, resolve discrepancies in field values during batch updating with the OriginalValue and UnderlyingValue properties. ================业精于勤荒于嬉,形成于思毁于随=================如果再给我一次爱的机会,我会好好的珍惜!
With rst
.Fields.Append "name", adBSTR, 10
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open
End With
If isnull(rst.Fields("Name")) Then
......
我也不知道isempty 和 isnull有什么不同!
知道了告诉我,咋俩在一个群。
Private Sub Command1_Click()
'rst.AddNew
'rst.Update
rst.MoveLast
If IsEmpty(rst.Fields("Name")) = True Then
MsgBox "null"
Else
MsgBox rst.Fields(0)
End If
End SubPrivate Sub Form_Load()
Dim t As Variant
rst.Fields.Append "Name", adVarChar, 30
rst.Open
rst.AddNew
rst.Fields("Name") = "1"
rst.Update
End Sub