locked
if a user types in their "user name" and password, how do i search the database for it? RRS feed

  • Question

  • I'm creating a forms application and I can't get one of my forms to work, how can I get my log in page to work and connect it to the database so that when a user enters their username/ password, it brings up the information which connects to them
    Wednesday, February 3, 2016 10:23 AM

Answers

All replies

  • Hello,

    That's not clear for me and to less on informations.

    How does your database design currently and your code to connect look like?


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Wednesday, February 3, 2016 10:50 AM
    Answerer
  • It's not really the database that's the problem, it's more my log in form. When the application runs, the form appears blank even though I've coded it and designed it. I can't figure out how to get the form to function. I also don't know how to write the correct SQL query so that when the user enters their username and password, the data is read from the database. I was using a select query but it isn't functioning.

     
    Wednesday, February 3, 2016 10:57 AM
  • Public

    ClassMyForm


       

    InheritsForm


       

    Dimcmd AsNewSqlCommand


       

    Dimda AsSqlDataAdapter


       

    DimMycon AsNewSqlConnection


       

    Subrun()

            Mycon =

    NewSqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=\\DS-FILE-STU\Intake2012$\bridie.honour\Documents\A2\Computer Science\WindowsApplication5\WindowsApplication5\Snowdon1.mdf;Integrated Security=True")

       

    EndSub


       

    PublicSubconnection(Mycon AsSqlConnection)

           

    Try


                Mycon.Open()

                MsgBox(

    "connected")

           

    Catchex AsException


                MsgBox(ex.Message)

           

    EndTry


       

    EndSub


        <

    STAThread>

       

    PublicSharedSubMain()

           

    Dimaform AsNewMyForm()

           

    Application.Run(MyForm)

       

    EndSub


       

    PrivateSubMyForm_Load(sender AsObject, e AsEventArgs) HandlesMyBase.Load

       

    EndSub

    Wednesday, February 3, 2016 10:58 AM
  • Hi Ebbzyboy1,

    As the issue is more related to programming in your application, I would recommend you post the question in the relevant application forum to get better support.

    Besides, you can review the following blog and similar thread about how to get data from SQL database display in different forms.
    Retrieve (Get) data from SQL Server database and display in ASP.Net GridView using C# and VB.Net
    retrieving data from SQL in VB (part 2)


    Thanks,
    Lydia Zhang


    Lydia Zhang
    TechNet Community Support


    Thursday, February 4, 2016 6:37 AM
  • Data Source=(LocalDB)\v11.0;AttachDbFilename=\\DS-FILE-STU\Intake2012$\bridie.honour\Documents\A2\Computer Science\WindowsApplication5\WindowsApplication5\Snowdon1.mdf;Integrated Security=True"

    Additional: You are Hosting the database file on a network share, it's may possible, but not supported and will end up in poor performance and with high risk of file/data inconsistency caused by network issues.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Thursday, February 4, 2016 7:46 AM
    Answerer