Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2004, 01:49 PM
Authorized User
 
Join Date: Jun 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default login script in vb.net

hi im new to vb.net and i was wondering if anyone can help me. i have a backend database in sqlserver2000, and a windows form developed in vb.net to access the data. i need a login script so only a selective few users can access the application.

 I have a table in my database called 'login' which has username and password fields.

 
Old March 27th, 2006, 06:50 AM
Registered User
 
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Am having the similar prob... & i am new to vb.net. I have tried below coding.... but its showing ("Invalid user name/password.")even i typed the right username and password and type. Anyone can advise me?

rivate Sub ENTER_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_enter.Click
        Dim conn As New SqlClient.SqlConnection("Data Source= (local); Initial catalog= CRS; user id=sa; pwd=sa")
        conn.Open()

        'Create a command object
        Dim mycommand As New SqlClient.SqlCommand("Select Username, Password, Type from Logindata Where Username = '" & txtUsername.Text & "' AND Password = '" & txtPassword.Text & "' AND Type= '" & Combotype.Text & "'", conn)

        'Execute the command
        Dim dr As SqlClient.SqlDataReader = mycommand.ExecuteReader()
        dr.Read()

        ' See if we got anything.
        If dr.Read = True Then
            Dim Frm2 As New Form2
            Frm2.Show()
        Else
            MsgBox("Invalid user name/password.")
        End If

        dr.Close()
        conn.Close()
    End Sub

 
Old March 31st, 2006, 03:41 AM
Registered User
 
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OKie.Surprisingly its working now. I just remove dr.Read() in the coding and its working fine. I do not know the reason ?? but its working hmm..







Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling one VB.NET script from another kwilliams VB.NET 2 September 11th, 2006 06:26 AM
login script: user can't hit "return" for login dmerrill Java Basics 13 July 14th, 2006 07:25 PM
login script Apocolypse2005 Javascript 3 June 24th, 2005 04:07 PM
login script in vb.net sand133 VB.NET 2002/2003 Basics 11 June 24th, 2004 06:13 AM
Login Script natmaster PHP How-To 10 June 19th, 2003 03:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.