Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to validate user input with SQL database using asp.net C#?

How to validate user input with SQL database using asp.net C#?

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasequestionasp-net
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    katelva
    wrote on last edited by
    #1

    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

    C H 2 Replies Last reply
    0
    • K 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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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.

      K 1 Reply Last reply
      0
      • C Christian Graus

        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.

        K Offline
        K Offline
        katelva
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • K 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

          H Offline
          H Offline
          Herman T Instance
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups