[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?
Re: Problem with sql conection
What is the error description?
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
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
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.