VB连接SQL数据库拒绝访问

来源:百度知道 编辑:UC知道 时间:2024/06/07 11:17:28
不是很会SQL 下面的数据库的登陆名和密码是多少??是否有错误?我登陆不了界面,数据库不存在或拒绝访问。。。。能帮下忙吗?在线等。。急用,谢谢
Option Explicit
Public con As ADODB.Connection
Public rct As ADODB.Recordset

Public Str_Str As String
Public Str_System As String
Public Num_System As Integer

'下面用于设置窗体的形状 API函数
Public Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Public Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

Public IsWhat As String
Public strSQL As String
'Public Str_admin As String
Public Admin_ID As String

Public Function Connect() As Boolean
On Error GoTo ON_ERROR
Set con = New ADODB.Connection
Set rct = New ADODB.Recordset
Dim llll As String
con.CursorLocation = adUseClient
con.ConnectionString = "Provider=SQLO

"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=LibraryManageSystem;Data Source=127.0.0.1"
这种写法的连接字符串有的时候确实连不上数据库

你可以试试这种
"server=127.0.0.1;uid=用户名;pwd=密码;database=数据库名"
这个写法简单但是很有效