|Okay - Now for part two: Inserting the data
I've abbreviated the code here, because it gets a little repetative, you should get the idea.
Create a stored procedure like this:
CREATE PROCEDURE UpdateUserDetails(@RecordID int, @Allowed int, @Name varchar(64), @Surname varchar(64),
@Class varchar(64), @Email varchar(64), @Username varchar(64), @Password varchar(64),
@Skin varchar(64), @ImagePath varchar(64))
-- Check to make sure the data exists already to be updated.
IF EXISTS(SELECT * FROM Users WHERE UserName = @UserName AND Password = @Password)
-- Perform the update, all fields, except UserName and Password are updated here
SET Allowed = @Allowed, Name = @Name, Surname = @Surname -- and so on....
WHERE UserName = @UserName AND Password = @Password
-- THere is no existing data to be updated, Raise and error - This will cause
-- a SqlException to be thrown in the .NET Application.
RAISERROR('The User does not exist', 16, 1);
-- Alternatively, an INSERT could be performed here.
GOIn the .NET application you would write some code similar to this:
Dim cmd As New SqlClient.SqlCommand("UpdateUserDetails", vilemConn)
cmd.CommandType = CommandType.StoredProcedure
' Keep adding parameters until all the parameters that the stored procedure takes are in.
' For consistency the parameters should be in the same order they appear in the stored procedure
A final note. RecordId appears to be the Primary Key for the Users table. It is not a good idea to update that. It can cause all sorts of problems with Foreign Key relationships and depending on how you have your SQL Server set up it would most likely cause an error.
Does this help?
"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!