Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Hamish Jones   on Jul 19 In Asp.net Category.

  
Question Answered By: Utsav Shah   on Jul 19

But i've still 2 other problems:

* why can't i read my userid => stockated in the first column of my database
(primary key and identity on!)
* when i'm using sessions here i get a message that i have to set the
enableSessionState...
Where can i do that, on the other forms in the same project, i didn't have to
do it...



Stored procedure:
*********************


CREATE PROCEDURE dbo.usp_SelectKlant
(
@KNaam char(20),
@Paswoord char(20)
)
AS
SET NOCOUNT ON;
SELECT KlantID, KNaam, Paswoord, SesID FROM KLANT WHERE (KNaam = @KNaam) AND
(Paswoord = @Paswoord)
GO

in region:
***********

Me.SqlSelectCommand1.CommandText = "[usp_SelectKlant]"
Me.SqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlSelectCommand1.Connection = Me.SqlConnection2
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int,
4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0,
Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@KNaam", System.Data.SqlDbType.VarChar, 20,
"KNaam"))
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Paswoord", System.Data.SqlDbType.VarChar,
20, "Paswoord"))

in code:

*********
Dim myName As String = txtName.Text.ToLower.Trim
Dim myPass As String = txtPassword.Text.ToLower.Trim

SqlSelectCommand1.Parameters("@KNaam").Value = myName
SqlSelectCommand1.Parameters("@Paswoord").Value = myPass
SqlConnection2.Open()

Dim myDataReader As System.Data.SqlClient.SqlDataReader
myDataReader = SqlSelectCommand1.ExecuteReader

If (myDataReader.Read) Then

Dim myKlantID As String = CType(myDataReader.GetString(0), String)
Dim myNameDB As String = myDataReader.GetString(1).ToLower.Trim
Dim myPassDB As String = myDataReader.GetString(2).ToLower.Trim

If ((myName.ToLower = myNameDB) And (myPass.ToLower = myPassDB)) Then

foutmelding.Text = "Gelukt"
Session("KlantID") = myKlantID
TextBox1.Text = myNameDB
TextBox2.Text = myPassDB
'...
Else
'niet ingelogd
foutmelding.Text = "Mislukt"
TextBox1.Text = myKlantID.ToString & "-" & myNameDB
TextBox2.Text = myPassDB & "-" & myPass
End If
Else
'niet ingelogd
foutmelding.Text = "mislukt"

End If

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How to use the DataReader. Or get search suggestion and latest updates.


Tagged: