|
-
Jul 10th, 2009, 12:37 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Problem with sql conection
i always did like this
Code:
cn.Provider = "SQLOLEDB"
cn.Properties("Data Source").Value = "127.0.0.1,1433"
cn.Properties("Initial Catalog").Value = "LevelDB"
cn.Properties("User ID").Value = "sa"
cn.Properties("Password").Value = "123456"
cn.Open
but now, i got the run-time error '3705'
why am i doing wrong?
-
Jul 10th, 2009, 12:42 PM
#2
Re: Problem with sql conection
What is the error description?
-
Jul 10th, 2009, 01:02 PM
#3
Re: Problem with sql conection
try just the IP address... no port... the default port is 1433, so it's not necessary to specify it.
-tg
-
Jul 10th, 2009, 01:29 PM
#4
Re: Problem with sql conection
If the description is "Operation is not allowed when the object is open" then you should close it before opening.
Code:
cn.Provider = "SQLOLEDB"
cn.Properties("Data Source").Value = "127.0.0.1,1433"
cn.Properties("Initial Catalog").Value = "LevelDB"
cn.Properties("User ID").Value = "sa"
cn.Properties("Password").Value = "123456"
If cn.state = adStateOpen Then
cn.Close
End If
cn.Open
Or you just have to open it if it is closed.
Code:
If cn.state = adStateClosed Then
cn.Open
End If
-
Jul 10th, 2009, 08:28 PM
#5
Thread Starter
Hyperactive Member
Re: Problem with sql conection
thanks, i was using a wrong if with exit sub without checking if the connection was realy opened, so it were opened, and when i try to open again return the error.
thanks, with both answers i could see my error. thanks a lot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|