| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 655 人关注过本帖, 1 人收藏
标题:用ADO添加修改数据记录
只看楼主 加入收藏
sun034
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-5-10
收藏(1)
 问题点数:0 回复次数:1 
用ADO添加修改数据记录
用ADO添加修改数据记录 用什么样的代码啊 我自己的老是出错  谁有这方面的代码 发上来啊 小弟我急啊 谢谢了 用DATA1添加的也行 我修改一下就好了
搜索更多相关主题的帖子: ADO 数据记录 
2006-05-14 20:22
hyhhd
Rank: 2
等 级:论坛游民
威 望:1
帖 子:502
专家分:44
注 册:2006-5-12
收藏
得分:0 

试试:
Public IfConnectionDataBase As Boolean
Public IfAddRecordset As Boolean

'''''''''''''''''''连接数据库''''''''''''''''''''''

Public Function LinkDataBase(LinkString As String, UserName As String, PassWord As String) As Connection
Dim Cnn As New Connection

On Error GoTo ProcError
Screen.MousePointer = 11

' Cnn.Mode = adModeRead

Cnn.Open LinkString, UserName, PassWord
Set LinkDataBase = Cnn

IfConnectionDataBase = True
Screen.MousePointer = 0

ProcExit:
Exit Function

ProcError:
Screen.MousePointer = 0
MsgBox "错误号:" & Err.Number & vbCrLf & Err.Description & "!", 48, "连接错误提示"
IfConnectionDataBase = False
Resume ProcExit

End Function
'''''''''''''''''''''''''添加记录''''''''''''''''''''''''''''

Public Sub AddNewRecordset(LinkString As String, UserName As String, PassWord As String, TableName As String, _
FieldName As String, FieldValues As String)

Dim SQL As String
Dim Cnn As New Connection

On Error GoTo ProcError
Screen.MousePointer = 11

SQL = " insert into " & TableName & " ( " & FieldName & " ) values ( " & FieldValues & " )"

Set Cnn = LinkDataBase(LinkString, UserName, PassWord)

' MsgBox SQL

Cnn.Execute SQL

IfAddRecordset = True
Screen.MousePointer = 0

ProcExit:
Exit Sub

ProcError:
Screen.MousePointer = 0
MsgBox "错误号:" & Err.Number & vbCrLf & Err.Description & "!", 48, "添加记录错误提示"
IfAddRecordset = False
Resume ProcExit
End Sub


2006-05-14 20:57
快速回复:用ADO添加修改数据记录
数据加载中...
 
   



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

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