我的msn: myfend@
数据库也行啊,可是小弟不会,请你帮帮我啊大侠!~~~~~~~
不会就去学吧,当今世界不会数据库好多东西都搞不好的
用SQL
把这放在模块里,这只是连接数据库部分
Dim msmsg As String
Public Function executesql(ByVal sql As String, msg As String) As ADODB.Recordset
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim stockens() As String
On Error GoTo executesql_error
stockens = Split(sql)
Set cn = New ADODB.Connection
cn.Open cns
If InStr("INSERT,DELETE,UPDATE", UCase$(stockens(0))) Then '把查询分开因为他不涉及数据修改
cn.Execute (sql)
msg = stockens(0) & "Successful"
Else
Set rs = New ADODB.Recordset
rs.Open Trim$(sql), cn, adOpenStatic, adLockOptimistic
Set executesql = rs
msg = "查询到" & rs.RecordCount & "条记录"
End If
executesql_exit:
Set rs = Nothing
Set cn = Nothing
Exit Function
executesql_error:
msg = "查询错误:" & Err.Description
Resume executesql_exit
End Function
Public Function cns() As String
cns = "Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=kjda;User ID=UserName;password=1111;" '是本地数据库就只用改Initial Catalog=kjda,password=1111,
End Function