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. New To VB.net Need Help

New To VB.net Need Help

Scheduled Pinned Locked Moved Visual Basic
databasecsharphelptutorial
8 Posts 4 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.
  • P Offline
    P Offline
    percyvimal
    wrote on last edited by
    #1

    Hello I am visual Basic 6 guy doing a project in VB.net now. Everything look different from visual basic 6 to .net. I need help in these things 1. I need to connect an odbc sql connection and how to set a public connection in module 2. what are the references i should have to add and how to add ( similar to how we add in vb 6) 3. Say i have a table called userTB and fields Usercode and userid and password. i need your help how to get these from the database and check and verify the username and password in a form called Login.vb If somebody can help me in this with coding and some descriptions then i can use that as a base and develop the applicaiton. Thanks and regards vimal Help in need is the help indeed

    C K 2 Replies Last reply
    0
    • P percyvimal

      Hello I am visual Basic 6 guy doing a project in VB.net now. Everything look different from visual basic 6 to .net. I need help in these things 1. I need to connect an odbc sql connection and how to set a public connection in module 2. what are the references i should have to add and how to add ( similar to how we add in vb 6) 3. Say i have a table called userTB and fields Usercode and userid and password. i need your help how to get these from the database and check and verify the username and password in a form called Login.vb If somebody can help me in this with coding and some descriptions then i can use that as a base and develop the applicaiton. Thanks and regards vimal Help in need is the help indeed

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

      It's not too late to redeem yourself. If you have the full VS.NET, just click on the C# project tab, and you can be saved... percyvimal wrote: I need to connect an odbc sql connection and how to set a public connection in module There are two groups of objects, if you're using SQL Server, then you want to open a System.Data.SqlClient.SqlConnection. percyvimal wrote: what are the references i should have to add and how to add ( similar to how we add in vb 6) System.Data. Anything else you need lives under there, and intellisense should reveal all. percyvimal wrote: Say i have a table called userTB and fields Usercode and userid and password. i need your help how to get these from the database and check and verify the username and password in a form called Login.vb Use a SqlCommand object ( same namespace as the connection ) to call the stored procedure that gives you this information. You're using a stored procedure, right ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      P 1 Reply Last reply
      0
      • C Christian Graus

        It's not too late to redeem yourself. If you have the full VS.NET, just click on the C# project tab, and you can be saved... percyvimal wrote: I need to connect an odbc sql connection and how to set a public connection in module There are two groups of objects, if you're using SQL Server, then you want to open a System.Data.SqlClient.SqlConnection. percyvimal wrote: what are the references i should have to add and how to add ( similar to how we add in vb 6) System.Data. Anything else you need lives under there, and intellisense should reveal all. percyvimal wrote: Say i have a table called userTB and fields Usercode and userid and password. i need your help how to get these from the database and check and verify the username and password in a form called Login.vb Use a SqlCommand object ( same namespace as the connection ) to call the stored procedure that gives you this information. You're using a stored procedure, right ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

        P Offline
        P Offline
        percyvimal
        wrote on last edited by
        #3

        Hello Mr Christian, Thanks for your reply.I am very very basic to vb.net and so i need more precise and elobarate descriptions with codings if possible. When i do this in vb6 this is how i do create a public connection in Public Db As Connection Sub Main() Set Db = New Connection Db.CursorLocation = adUseClient Db.Open "Provider=SQLOLEDB.1;Password=" & Password & ";Persist Security Info=True;User ID=" & userName & ";Initial Catalog= " & DataBaseName & " ;Data Source=" & ServerName & "" Frmlogin.Show 1 End Sub this is used in module. SO when i run the program it go to main function automatically. So how i do this in vb.net, same thing but how to do in vb.net Please explain to me in detail with codings and explain to me what referece to add and from where i have to add the reference. I am not using Stored procedure this is how i open a recordset using vb6 Dim Logrs as new recordset set Logrs= New recordset LogRs.Open "select [LoginID], [UserName],[password] from loginmaster where [UserName]='" & Trim(TxtUserName.Text) & "'", Db, adOpenDynamic, adLockOptimistic If LogRs.RecordCount <> 0 Then If LogRs.Fields("password") = Encrypt(Trim(txtnewPwod.Text)) Then LoginId = Val(LogRs.Fields("LoginID")) Unload Me Administrator = False FrmDonor.Show 1 Else MsgBox "Wrong password", vbCritical, App.ProductName Exit Function End If Else MsgBox "Username not exists", vbCritical, App.ProductName End If So how i can do this using vb.net, Thanks and regards vimal Help in need is the help indeed

        C 1 Reply Last reply
        0
        • P percyvimal

          Hello Mr Christian, Thanks for your reply.I am very very basic to vb.net and so i need more precise and elobarate descriptions with codings if possible. When i do this in vb6 this is how i do create a public connection in Public Db As Connection Sub Main() Set Db = New Connection Db.CursorLocation = adUseClient Db.Open "Provider=SQLOLEDB.1;Password=" & Password & ";Persist Security Info=True;User ID=" & userName & ";Initial Catalog= " & DataBaseName & " ;Data Source=" & ServerName & "" Frmlogin.Show 1 End Sub this is used in module. SO when i run the program it go to main function automatically. So how i do this in vb.net, same thing but how to do in vb.net Please explain to me in detail with codings and explain to me what referece to add and from where i have to add the reference. I am not using Stored procedure this is how i open a recordset using vb6 Dim Logrs as new recordset set Logrs= New recordset LogRs.Open "select [LoginID], [UserName],[password] from loginmaster where [UserName]='" & Trim(TxtUserName.Text) & "'", Db, adOpenDynamic, adLockOptimistic If LogRs.RecordCount <> 0 Then If LogRs.Fields("password") = Encrypt(Trim(txtnewPwod.Text)) Then LoginId = Val(LogRs.Fields("LoginID")) Unload Me Administrator = False FrmDonor.Show 1 Else MsgBox "Wrong password", vbCritical, App.ProductName Exit Function End If Else MsgBox "Username not exists", vbCritical, App.ProductName End If So how i can do this using vb.net, Thanks and regards vimal Help in need is the help indeed

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

          I absolutely do not use VB, or VB.NET, my answer is based on my knowledge of the .NET framework. I suggest you look at the MSDN entries for the classes I pointed you to, they are bound to have a full example in VB.NET. And security that isn't locked down so it can only be accessed via a stored procedure is not remotely secure :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

          A 1 Reply Last reply
          0
          • C Christian Graus

            I absolutely do not use VB, or VB.NET, my answer is based on my knowledge of the .NET framework. I suggest you look at the MSDN entries for the classes I pointed you to, they are bound to have a full example in VB.NET. And security that isn't locked down so it can only be accessed via a stored procedure is not remotely secure :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Hi, I was wondering what you meant by "And security that isn't locked down so it can only be accessed via a stored procedure is not remotely secure"? Does that mean that stored procedures are more secure? and are they faster/give faster data retrieval results in large database applications?

            C 1 Reply Last reply
            0
            • A Anonymous

              Hi, I was wondering what you meant by "And security that isn't locked down so it can only be accessed via a stored procedure is not remotely secure"? Does that mean that stored procedures are more secure? and are they faster/give faster data retrieval results in large database applications?

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

              Anonymous wrote: Does that mean that stored procedures are more secure? Absolutely. If your app uses plain SQL, then your user needs the right to arbitrarily execute SQL, which means that you open yourself to all sorts of attacks ( basically because the user has full access to the database ). If you use stored procedures, then give the user only the right to run a stored procedure, then they are unable to hack in a query that asks for all usernames and passwords, and instead can just run the stored procedure ( which returns true or false to a username/password combinatin passed in ). Anonymous wrote: are they faster/give faster data retrieval results in large database applications? Yes, because they are precompiled ( so long as they are properly written ) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

              1 Reply Last reply
              0
              • P percyvimal

                Hello I am visual Basic 6 guy doing a project in VB.net now. Everything look different from visual basic 6 to .net. I need help in these things 1. I need to connect an odbc sql connection and how to set a public connection in module 2. what are the references i should have to add and how to add ( similar to how we add in vb 6) 3. Say i have a table called userTB and fields Usercode and userid and password. i need your help how to get these from the database and check and verify the username and password in a form called Login.vb If somebody can help me in this with coding and some descriptions then i can use that as a base and develop the applicaiton. Thanks and regards vimal Help in need is the help indeed

                K Offline
                K Offline
                KevinMac
                wrote on last edited by
                #7

                Depending on the size of the project I almost always start out using the Data Access Application Block for .NET they are free and will save you a ton of work. It is a great starting point to both learn from and get in the right habits for writing good code. In VB 6 there were a lot of public connections used however in .Net you will find a more defined seperation between the datalayer and the rest of your application. ">href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp">[">^] Your question covers way to much to send in a message but let me try. In your case I would create a class objLogin, interface Ilogin, class dbLogin. Make the objLogin and dbLogin implement Ilogin that way they both have matching properties(this is the contract between objects) whenever you pass objLogin to dbLogin. The application block is your database class and is very generic so whenever you create an instance of it in your dbLogin class it will create a connection object and command object the dbLogin object uses to access the database. I know this all sounds absurd but I have not written a Data Access Object in over a year now. I don't have to since it is generic and reusable I use the same one over and over. As for the rest of the objects once you get the hang of it they are easy to do. I hope this helps point you in the right direction to find the answers you are looking for. Just remember to get the Data Access Application Blocks and hit a few articles on interfaces and you will be on your way. Oh yeah one more thing. Use Try Catch Finally in VB.net especially in your database classes or many bad things will happen to your app. Good Luck

                P 1 Reply Last reply
                0
                • K KevinMac

                  Depending on the size of the project I almost always start out using the Data Access Application Block for .NET they are free and will save you a ton of work. It is a great starting point to both learn from and get in the right habits for writing good code. In VB 6 there were a lot of public connections used however in .Net you will find a more defined seperation between the datalayer and the rest of your application. ">href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp">[">^] Your question covers way to much to send in a message but let me try. In your case I would create a class objLogin, interface Ilogin, class dbLogin. Make the objLogin and dbLogin implement Ilogin that way they both have matching properties(this is the contract between objects) whenever you pass objLogin to dbLogin. The application block is your database class and is very generic so whenever you create an instance of it in your dbLogin class it will create a connection object and command object the dbLogin object uses to access the database. I know this all sounds absurd but I have not written a Data Access Object in over a year now. I don't have to since it is generic and reusable I use the same one over and over. As for the rest of the objects once you get the hang of it they are easy to do. I hope this helps point you in the right direction to find the answers you are looking for. Just remember to get the Data Access Application Blocks and hit a few articles on interfaces and you will be on your way. Oh yeah one more thing. Use Try Catch Finally in VB.net especially in your database classes or many bad things will happen to your app. Good Luck

                  P Offline
                  P Offline
                  percyvimal
                  wrote on last edited by
                  #8

                  Thanks Mr KevinMac The link u have given me was really useful. I think i have to be working on some oops concepts before going into .net. I used plain visual basic 6 and i found no difficulties in working with that.But when i started .net all look "Greek and Latin", and so i dont know where to start. Am i need to use modules and classes the same way i do it vb6 and same way for forms etc.. SO all these made me really confused and i searched for articles which will give me some ideas how to begin but nothing there for begginers like me. To be frank "In your case I would create a class objLogin, interface Ilogin, class dbLogin. Make the objLogin and dbLogin implement Ilogin that way they both have matching properties(this is the contract between objects) whenever you pass objLogin to dbLogin. " I couldnt able to understand what it actually means. So i expect a very basic level explanation, ( more like refering this from vb6 to vb.net mode) Thank you very much mate for you helps with regards vimal Help in need is the help indeed

                  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