¹«¹²Ä£¿é£º
Private Function Selectsql(SQL As String) As ADODB.Recordset '·µ»ØADODB.Recordset¶ÔÏó
Dim ConnStr As String
Dim Conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set Conn = New ADODB.Connection
'On Error GoTo MyErr:
ConnStr = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=µÇ¼Êý¾Ý¿âÓû§Ãû(ĬÈÏΪsa);Password=µÇ¼Êý¾Ý¿âÃÜÂë;Initial Catalog=Êý¾Ý¿âÃû;Data Source=·þÎñÆ÷Ãû(IPµØÖ·)" 'ÕâÊÇÁ¬½ÓSQLÊý¾Ý¿âµÄÓï¾ä
Conn.Open ConnStr
rs.CursorLocation = adUseClient
rs.Open Trim$(SQL), Conn, adOpenDynamic, adLockOptimistic
End Function
µ÷Óãº
SQL = "SELECT * FROM Óû§±í WHERE Óû§Ãû='" & Combo1.Text & "' AND ÃÜÂë='" & Text1.Text & "' "
Set rs = Selectsql(SQL)