文件名称:vb远程连接sqlserver数据库
文件大小:2KB
文件格式:FRM
更新时间:2012-09-28 11:20:33
数据库
Private Sub Command1_Click() Dim conn As New ADODB.Connection Dim s As String Dim rs As New ADODB.Recordset Dim telephone As String Dim txtsql As String telephone = Trim(Text1.Text) '******************************************************************************************* s = "Driver={SQL Server}; Database=phone; UID=sa; PWD=oallserver; Server=10.47.1.12 " conn.ConnectionString = s conn.Open txtsql = "select * from tellphone where phone_id ='" & telephone & "'" Set rs = New ADODB.Recordset rs.Open txtsql, conn, _ adOpenKeyset, _ adLockOptimistic Text2.Text = rs.Fields(1) End Sub Private Sub Form_Load() Text1.Text = "" Text2.Text = "" End Sub