-
Hi Everybody!
I hope you can help me. I have my application logging into my SQL server 7.0 for user security. I can log in to my login screen, but the application seems to not hold on to the username and password when I try to open other forms in the application. It gives me this error:
Run-time error '-2147217843(80040e4d)':
Login failed for user '(null)'
Here is a sample of what I have on Form_load on the forms that give me the error:
Code:
Set cn = New Connection
cn.Provider = "SQLOLEDB.1"
cn.ConnectionString = "DATABASE=QCManager;SERVER=d248r00b;UID=" & A_Sign_On.txtuName.Text & ";PWD=" & A_Sign_On.txtPword.Text & ";"
cn.Open
A_Sign_On.txtuName.Text and A_Sign_On.txtPword.Text are the username and password respectively. A_Sign_On is the form where the user puts in the username and password.
Any ideas on how to solve this problem?
Thanks in advance.
-
?!
That could eb the wrong answer
but have not tried it or anything
and am not sure which version of VB u're using
Try
'A.signon!textname.text' etc..
-
Hmm...
My version for VB is 6.0, Service Pack 4, and SQL 7.0 Service Pack 2. Still did not work with
A_Sign_On!txtuName.Text
Any assistance would be greatly appreciated.
-
..
Hi!
Try this... (quickie also)
Q. Is your form still loaded (i.e the form that contains the password...?
Debug a bit with msgbox...
(or I can send u a small function that I use)
Dim cn As ADODB.Connection
Dim strCnn As String
dim myuserID, mypwd
myuserID = A_Sign_On.txtuName.Text
msgbox myuserID
mypwd = A_Sign_On.txtPword.Text
msgbox mypwd
' Open connection.
strCnn = "Provider=sqloledb;" & _
"Data Source=d248r00b;Initial Catalog=QCManager;User Id=" & myuserID & " ;Password= " & mypwd & "; "
Set cn = New ADODB.Connection
with cn
.ConnectionTimeout = 30000 'a little bit more than 2hrs
.CommandTimeout = 30000
.open strCnn
end with
-
Hi!
Yes , my form where the user has put in the username and password is unloaded. Basically, I need for the username and password to follow the user all over the application until he/she logs out of the app.
Any ideas?
Thanks again in advance.
-
global var
put it in a global variable
under General ---> Declarations section
in a module or your frm
Public SaveUserID as string
Public SavePwd as string
then right where u have these pieces of info
do
SaveUserID = ...
etc..
then u should be able to reference these global vars
from anywhere with your prog
-
Thanks!
It is working!!!!!! Thanks for your help.