you anwered:
Dunno on (a) ... I've forgotton all my SQL since messing with controls
(... and good
riddance, boring, boring, boring)
Dim myKlantID As String = CType(myDataReader.GetString(0), String)
Dim myNameDB As String = myDataReader.GetString(1).ToLower.Trim
<<--- why no Ctype ?
Dim myPassDB As String = myDataReader.GetString(2).ToLower.Trim
<<--- why no Ctype ?
the problem isn't in myNameDB and myPassDB, those work just fine cos they are
already varchars in my database i guess...
But myKlantID is an integer + primary key + identity (for autoincrementing) is
on
and there it don't work...
will give another code snippet:
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)
<<<<<<<<<<<<<<<<<don't go...
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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< don't
go...
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