|First, an optimisation tip. Although I'm thinking it may not be important in VB.NET as the ByVal and ByRef must be declared in method parameters - In C# classes are by reference by default and structures are by value by default. However, I still think the general rule is sound that a structure should always be small (no more than 16 bytes is one figure I've heard). So, for something like this a class would be better (in my opinion).
Looking at the structure you've given. I'm assuming that RecordId is the primary key of the table. If that is the case then UserName should have a unique constraint applied to it also to make sure that two users with the same UserName do not get inserted in the database.
Disclaimer: I've tried to write in VB.NET, which isn't my language - I've not done any VB since version 3, so please be aware that there may be errors in the syntax.
To get the data from the database create a stored procedure that is similar to this:
CREATE PROCEDURE GetUserDetails(@UserName varchar(64), @Password varchar(64))
-- This should always return zero or one records only.
SELECT RecordId, Allowed, Name, Surname, Class, Email, UserName, Password, Skin, ImagePath
WHERE Username = @UserName
AND Password = @Password
GO Then in your .NET application some code like this:
Dim cmd As New SqlClient.SqlCommand("GetUserDetails", vilemConn)
cmd.CommandType = CommandType.StoredProcedure
' The data from the Select can be returned in to a DataSet or through a DataReader
' As you are populating your own structure it is probably better to use the DataReader
Dim dataReader As cmd.ExecuteDataReader()
Dim details As New UserData()
' A record has returned from the Stored Procedure
' The numbers in the GetInt32 / GetString methods refer to
' the position of the field. So, care must be taken to SELECT
' the fields in the same order in the stored procedure.
details.strRecordId = dataReader.GetInt32(0)
details.strName = dataReader.GetString(2)
details.strSurname = dataReader.GetString(3)
details.strClass = dataReader.GetString(4)
details.strEmail = dataReader.GetString(5)
details.strUserName = dataReader.GetString(6)
details.strPassword = dataReader.GetString(7)
details.strSkin = dataReader.GetString(8)
details.strImagePath = dataReader.GetString(9)
' There is no record, therefore the user name and password don't match
' TODO: Put code here that will handle the failed login details.
As this is quite a long reply... I'll continue in part two (Inserting the data) in a little while...
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!