Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Stored Procedure

Author  Topic 

michelle55
Starting Member

7 Posts

Posted - 2011-04-12 : 17:31:23
Hi I am trying to do a Login stored procedure with using email address and password

Would it be like this:

create procedure [dbo].[Get_Customer_Login]
(
@password nvarchar(255)
@email nvarchar(255)

)
as
select * from tblCustomers$
where Password = @password
and emailaddr = @emailaddr

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-12 : 17:32:26
You shouldn't use "select *", but it looks fine. Are you having a problem?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

michelle55
Starting Member

7 Posts

Posted - 2011-04-12 : 17:39:47
yes i'm trying to connect it to visual studio using the run procedure:

Public Sub RunProcedure(ByVal strName As String)
' purpose: Runs any stored procedure that does NOT need parameters
' inputs: Name of stored procedure

' CREATES INSTANCES OF THE CONNECTION AND COMMAND OBJECT
Dim objConnection As New SqlConnection(mstrConnection)
' Tell SQL server the name of the stored procedure you will be executing
Dim objCommand As New SqlDataAdapter(strName, objConnection)
Try
' SETS THE COMMAND TYPE TO "STORED PROCEDURE"
objCommand.SelectCommand.CommandType = CommandType.StoredProcedure

' OPEN CONNECTION AND FILL DATASET


objCommand.Fill(mDataset, "tblMovies")
' Me.mdbConn.Close()
' Me.mdbConn.Open()
MyView.Table = Me.mDataset.Tables("tblMovies")

Catch ex As Exception
Throw New Exception("stored procedure is " & strName.ToString & " error is " & ex.Message)
End Try

End Sub

and then how would i connect that to the form where it has two textboxes one for email and password and then a login button?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-12 : 17:41:56
I haven't a clue as that's a programming question. You should add "SET NOCOUNT ON" right after the AS to avoid having an additional result set returned that you weren't expecting in your application.

It would probably be helpful to post the error as I don't see one in your post.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

michelle55
Starting Member

7 Posts

Posted - 2011-04-12 : 17:42:03
wait it's not working now in sql with those two email and password.. was the coding for them or should it be different
Go to Top of Page

michelle55
Starting Member

7 Posts

Posted - 2011-04-12 : 17:47:30
create procedure [dbo].[Get_Customer_Login]
(
@password nvarchar(255)
@emailaddr nvarchar(255)
)
as
select * from tblCustomers$
WHERE Emailaddr = @Emailaddr AND Password = @Password
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-12 : 17:51:35
You'll have to be more detailed with "not working now in sql".

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

michelle55
Starting Member

7 Posts

Posted - 2011-04-12 : 18:16:49
so i am trying to do the login with password and email but i couldn't do it with both in one procedure in sql so now i am doing it in two

Public Sub GetEmailAddress()
RunProcedure("usp_Get_By_Email_Address")

End Sub

Public Sub GetCustomerPassword()
RunProcedure("usp_Get_Customer_Password")

End Sub

Public Sub FilterViewByEmailAddress(ByVal strIN As String)
MyView.RowFilter = "EmailAddr Like '" & strIN & "'"
End Sub

Public Sub FilterViewByCustomerPassword(ByVal strIN As String)
MyView.RowFilter = "Password Like '" & strIN & "'"
End Sub


Public Sub FilterViewByBoth(ByVal EmailAddr As String, ByVal Password As String)
MyView.RowFilter = "EmailAddr Like '" & EmailAddr & "' AND Password Like '" & Password & "'"
End Sub

that's what i have in my customerdatabaseclass and i want to refer it to the form now but in the filter()
my coding is not connecting to the class

i have:


Public Sub Filter()
Dim stremailadress As String = txtEmailAddress.Text
Dim strpassword As String = txtPassword.Text



If stremailadress <> "" And strpassword <> "" Then
lblMessage.Text = "Please enter a valid login!"
End If

If DB.FilterViewByBoth(stremailadress, strpassword) Then
lblMessage.Text = "Correct Login!"
End If




End Sub


because in the signin button ill only have filter there as coding

Go to Top of Page

michelle55
Starting Member

7 Posts

Posted - 2011-04-12 : 18:18:15
this is how my form looks:


Please Sign In or Create a Safari Account
Email Address: 
Password:           

signinbutton

[lblMessage]
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-12 : 18:21:12
I can't help you with the application programming, but I would highly recommend testing your stored procedure in Management Studio to ensure it is working first. If it is working there, then the problem is in your application code.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

michelle55
Starting Member

7 Posts

Posted - 2011-04-12 : 18:21:57
okay i will thank you
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-12 : 18:25:34
Here's an example test in SSMS:

EXEC Get_Customer_Login @password = 'SomePassword', @emailaddr = 'SomeEmail@SomeDomain.com'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -