How to validate user input with SQL database using asp.net C#?
-
Hi, I have created a login page using asp.net C#(not using login control).But I am wondering how to I validate the user input with SQL database? I have created a login.aspx with user input username and password, I put the code in login.aspx.cs,but I am not sure the syntax for asp.net in C#. So far, all the codes I search are for VB.net. I am not sure how do I validate user input with SQL database using asp.net in C#? Do anyone have any recommended websites for this? Thanks. Regards, Katelva
-
Hi, I have created a login page using asp.net C#(not using login control).But I am wondering how to I validate the user input with SQL database? I have created a login.aspx with user input username and password, I put the code in login.aspx.cs,but I am not sure the syntax for asp.net in C#. So far, all the codes I search are for VB.net. I am not sure how do I validate user input with SQL database using asp.net in C#? Do anyone have any recommended websites for this? Thanks. Regards, Katelva
I think you're asking how to call a SQL database. You could only find VB examples ? They are easy to convert, and there's web sites that do it for free. Also, the code is the same if it's ASP.NEt or not, you just need to get some C# ADO.NET examples. Plenty on this site and elsewhere.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
I think you're asking how to call a SQL database. You could only find VB examples ? They are easy to convert, and there's web sites that do it for free. Also, the code is the same if it's ASP.NEt or not, you just need to get some C# ADO.NET examples. Plenty on this site and elsewhere.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
Hi Christian, Can you give me the recommended website of learning asp.net using language C#, I am newbie to asp.net C#, so I am not sure how to read the data from SQL Express database and validate the user input from the database using asp.net C#. Mostly from book and internet are in VB language. The bottom is my source code where I have tried to use SQLdataReader: protected void btnSubmit_Click(object sender, EventArgs e) { string uname = txtUserName.Text; string pwd = txtPassword.Text; string connectionString = "Data Source= .\\SQLEXPRESS;" + "AttachDbFilename=\"C:\\Documents and Settings\\kathy\\My Documents\\Visual Studio 2008\\WebSites\\WebSite1\\App_Data\\salon.mdf\";" + "Integrated Security=True;" + "User Instance=True"; SqlConnection myConnection = new SqlConnection(connectionString); SqlCommand cmd = myConnection.CreateCommand(); cmd.CommandText = "SELECT * FROM [Customer]"; myConnection.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr.GetOrdinal("UserName").ToString() == txtUserName.Text) { Response.Write("Heelo"); //dr.Close(); } //dr.Close(); myConnection.Close(); } } Thanks. Regards, Katelva
-
Hi, I have created a login page using asp.net C#(not using login control).But I am wondering how to I validate the user input with SQL database? I have created a login.aspx with user input username and password, I put the code in login.aspx.cs,but I am not sure the syntax for asp.net in C#. So far, all the codes I search are for VB.net. I am not sure how do I validate user input with SQL database using asp.net in C#? Do anyone have any recommended websites for this? Thanks. Regards, Katelva
you should do a Binary_checksum in your SQL: Example of a Stored Procedure with Binary_Checksum: CREATE procedure [dbo].[SE_SelSecUserCredentials] @UserName NVARCHAR(45), @PassWord NVARCHAR(45) AS begin SELECT ......., ............., ........ FROM UserTable WHERE active = 1 AND BINARY_CHECKSUM(loginName) = BINARY_CHECKSUM(@UserName) AND BINARY_CHECKSUM(password) = BINARY_CHECKSUM(@PassWord) end