|
-
Sep 18th, 2007, 03:44 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED]Can you help me solve my problem ? Thanks you
VB Code:
Private Sub cmdLogin_Click()
Dim pStrLoginWhere As String
Dim rSLogin As Recordset
Dim DecryptedPass As String
Call ValidateEmptyField(frmlogin)
pStrLoginWhere = " WHERE User_ID = '" & txtUname.Text & "'"
Set rSLogin = SQLSELECT("*", "UserControl", pStrLoginWhere, "", "", "Maintenance")
If Not (rSLogin.BOF = True Or rSLogin.EOF = True) Then
DecryptedPass = RndCrypt(rSLogin!Password, "Password")
If txtPassword.Text = DecryptedPass Then
gstrUserGroup = rSLogin!Position
gstrUserID = rSLogin!User_ID
Me.Hide
MDIMaintenance.Show
Else
MsgBox "Invalid Password, Please Try again", vbOKOnly, "Invalid Login"
Call HighLight(txtPassword)
End If
Else
MsgBox "Invalid User Name Login.try again!", vbOKOnly, "Login!!"
Call HighLight(txtUname)
End If
End Sub
Public Sub SQLExecute(pstrDBName As String)
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
"Persist Security Info=true;" & _
"Initial Catalog=Maintenance;User Id=;Password=;Data Source=SHLIM\SQLEXPRESS;"
conn.Open
End Sub
Public Function SQLSELECT(pstrFIELD As String, pstrTABLE As String, pstrWHERE As String, pstrGROUPBY As String, pstrOrderBy As String, pstrDBName As String) As ADODB.Recordset
Dim pstrSELECT As String
pstrSELECT = " SELECT " & pstrFIELD & " FROM " & pstrTABLE & pstrWHERE & _
pstrGROUPBY & pstrOrderBy
Call SQLExecute(pstrDBName)
[U][I] SQLSELECT.Open pstrSELECT, conn, adOpenKeyset, adLockPessimistic, adCmdText [/I][/U]
End Function
Please help me check my code contains any problem because i obtain error of -- > Object variable or with block variable not set.
Thanks !!!
Last edited by nUflAvOrS; Sep 18th, 2007 at 04:47 AM.
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Sep 18th, 2007, 03:58 AM
#2
Frenzied Member
Re: Can you help me solve my problem ? Thanks you
where have u declared conn?
-
Sep 18th, 2007, 04:00 AM
#3
Thread Starter
Hyperactive Member
Re: Can you help me solve my problem ? Thanks you
Sorry Sir,
i had declared it in my project
i forgot to attach it together
VB Code:
Private conn as ADODB.Connection
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Sep 18th, 2007, 04:08 AM
#4
Addicted Member
Re: Can you help me solve my problem ? Thanks you
In your code the function SQLSELECT return the recordset.
You need to declare one local recordset and then open it and return it as the function value
vb Code:
Public Function SQLSELECT(pstrFIELD As String, pstrTABLE As String, pstrWHERE As String, pstrGROUPBY As String, pstrOrderBy As String, pstrDBName As String) As ADODB.Recordset
Dim pstrSELECT As String
pstrSELECT = " SELECT " & pstrFIELD & " FROM " & pstrTABLE & pstrWHERE & _
pstrGROUPBY & pstrOrderBy
Call SQLExecute(pstrDBName)
Dim x as ADODB.RECORDSET
SET x=new ADODB.RECORDSET
x.Open pstrSELECT, conn, adOpenKeyset, adLockPessimistic, adCmdText
SQLSELECT=x
End Function
Do Good. Be Good. The World is yours.
-
Sep 18th, 2007, 04:42 AM
#5
Thread Starter
Hyperactive Member
Re: Can you help me solve my problem ? Thanks you
 Originally Posted by vksingh24
In your code the function SQLSELECT return the recordset.
You need to declare one local recordset and then open it and return it as the function value
vb Code:
Public Function SQLSELECT(pstrFIELD As String, pstrTABLE As String, pstrWHERE As String, pstrGROUPBY As String, pstrOrderBy As String, pstrDBName As String) As ADODB.Recordset
Dim pstrSELECT As String
pstrSELECT = " SELECT " & pstrFIELD & " FROM " & pstrTABLE & pstrWHERE & _
pstrGROUPBY & pstrOrderBy
Call SQLExecute(pstrDBName)
Dim x as ADODB.RECORDSET
SET x=new ADODB.RECORDSET
x.Open pstrSELECT, conn, adOpenKeyset, adLockPessimistic, adCmdText
SQLSELECT=x
End Function
Thank Sir
I had tried your method, but i used
else it prompt me an error message.
How ever my rslogin always return NOTHING
and Prompt me an error message Type mismatch.
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Sep 18th, 2007, 04:45 AM
#6
Thread Starter
Hyperactive Member
Re: Can you help me solve my problem ? Thanks you
Oppss !! I solved the problem
i must declare
vb Code:
Dim rSLogin As adodb.Recordset
Instead of
Thanks sir , you help me a lot.
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
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
|