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. General Programming
  3. Visual Basic
  4. Creating Logon screen with SQL Connection

Creating Logon screen with SQL Connection

Scheduled Pinned Locked Moved Visual Basic
databasesql-serversysadmin
6 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.
  • S Offline
    S Offline
    Shrimpersfan
    wrote on last edited by
    #1

    I have just started creating a new vb application which requires a login screen. I have created a new database in sql server 2000 which holds the usernames and passwords. I was wondering how i would create the connection and then link the username and password text boxes to the fields in the database. Regards. David

    J 1 Reply Last reply
    0
    • S Shrimpersfan

      I have just started creating a new vb application which requires a login screen. I have created a new database in sql server 2000 which holds the usernames and passwords. I was wondering how i would create the connection and then link the username and password text boxes to the fields in the database. Regards. David

      J Offline
      J Offline
      Jon_Boy
      wrote on last edited by
      #2

      Do you have any code to show what you've attempted thus far?

      Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

      S 1 Reply Last reply
      0
      • J Jon_Boy

        Do you have any code to show what you've attempted thus far?

        Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

        S Offline
        S Offline
        Shrimpersfan
        wrote on last edited by
        #3

        Public Class Private sqlConn AS SQLConnection = New Sql Connection (connectionstring) Private sub LoginScript() SqlConn.open DIM SqlCmd AS New SQLCommand = (StoredProcdure, SqlConn) Dim SqlAdapter as sqldataadapter = new sqlAdapter(sqlCmd) Dim dt as new DataTable SqlAdapter.fill(dt) IF dt.select("username = " +txtUserName.text + "AND password = " + txtPassword.text) > 0 THEN 'login Else msgbox("Login Failed", "Login Failed", vbOK) END IF END sub

        D 1 Reply Last reply
        0
        • S Shrimpersfan

          Public Class Private sqlConn AS SQLConnection = New Sql Connection (connectionstring) Private sub LoginScript() SqlConn.open DIM SqlCmd AS New SQLCommand = (StoredProcdure, SqlConn) Dim SqlAdapter as sqldataadapter = new sqlAdapter(sqlCmd) Dim dt as new DataTable SqlAdapter.fill(dt) IF dt.select("username = " +txtUserName.text + "AND password = " + txtPassword.text) > 0 THEN 'login Else msgbox("Login Failed", "Login Failed", vbOK) END IF END sub

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          I would highly recommend picking up a book on VB.NET and SQL Server and working through them before taking this project on. The code you're written so far is terrible and if you continue to use the techniques you've demonstrated so far, your project is going to fail miserably. Amazon results[^]

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            I would highly recommend picking up a book on VB.NET and SQL Server and working through them before taking this project on. The code you're written so far is terrible and if you continue to use the techniques you've demonstrated so far, your project is going to fail miserably. Amazon results[^]

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            S Offline
            S Offline
            Shrimpersfan
            wrote on last edited by
            #5

            I have recently read a VB book, as you can imagine, i am a complete novice when it comes to vb and programming. I have written this piece of code. I was wondering if you could tell me if this would create a valid connection or not. Imports System Imports System.Data Imports System.Data.SqlClient Public Class frmLogin Public sqlconnection As SqlConnection = New SqlConnection("Data Source=TG-IT-TPSRV;Initial Catalog=AFQ;User ID=sa;Password=;") Public Sub frmLogin() Dim sqlConn As SqlConnection = sqlconnection Dim sqlComm As String = ("SELECT * FROM Users") End Sub Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Close() End Sub Public Sub Logon_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click Dim sConnectionString As String = "Source=TG-IT-TPSRV;Initial Catalog=AFQ;User ID=sa;Password=;" Dim objConn As New SqlConnection(sConnectionString) Dim sqlComm As String = ("SELECT * FROM Users") Dim objComm As New SqlCommand(sqlComm, sqlconnection) objConn.Open() End Sub End Class

            D 1 Reply Last reply
            0
            • S Shrimpersfan

              I have recently read a VB book, as you can imagine, i am a complete novice when it comes to vb and programming. I have written this piece of code. I was wondering if you could tell me if this would create a valid connection or not. Imports System Imports System.Data Imports System.Data.SqlClient Public Class frmLogin Public sqlconnection As SqlConnection = New SqlConnection("Data Source=TG-IT-TPSRV;Initial Catalog=AFQ;User ID=sa;Password=;") Public Sub frmLogin() Dim sqlConn As SqlConnection = sqlconnection Dim sqlComm As String = ("SELECT * FROM Users") End Sub Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Close() End Sub Public Sub Logon_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click Dim sConnectionString As String = "Source=TG-IT-TPSRV;Initial Catalog=AFQ;User ID=sa;Password=;" Dim objConn As New SqlConnection(sConnectionString) Dim sqlComm As String = ("SELECT * FROM Users") Dim objComm As New SqlCommand(sqlComm, sqlconnection) objConn.Open() End Sub End Class

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Yeah, it would create a connection, but your design is going to cause you problems down the road.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008

              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