如何打开SQLServer2000数据库
Set g_conn = New Connection ServerName = "localhost" DBname = "mytest" UserName = "sa" strPwd = ""with g_conn .ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;" & _ "User ID=" & UserName & ";Initial Catalog=" & DBname & _ ";Data Source=" & ServerName & ";pwd=" & strPwdend with
Private Sub Form_Load() Dim g_conn As New ADODB.Connection Dim g_rst As New ADODB.Recordset ServerName = "localhost" DBname = "hyel" '"mytest" UserName = "sa" strPwd = "" With g_conn .ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;" & _ "User ID=" & UserName & ";Initial Catalog=" & DBname & _ ";Data Source=" & ServerName & ";pwd=" & strPwd End With g_conn.CursorLocation = adUseClient g_conn.Open g_rst.Open "select * from zd_yhb", g_conn, adOpenStatic, adLockPessimistic Set DataGrid1.DataSource = g_rstEnd Sub