I do it this way for myself as it one, looks cleaner, and two, is easier for me to debug.
The way he is talking about is that you can set almost all your values while at Dim, like below:
Dim conLogin As New OdbcConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString"))
this specific string reduces the code above by 4 lines, but people just have their own ways of doing it as it suits them better.
You can also elminite the parameters added by just including them directly into the SQL query like:
Dim cmdSelectLoginfo As New OdbcCommand( "SELECT UserID FROM Users WHERE UserName=" & ((txtUsername.Text.Trim()).ToString()) & " AND UserPassword=" & ((txtPassword.Text.Trim()).ToString()), conLogin )
this line reduces code by 5 lines. Use what is best for you for debugging. After making sure it works the way you desire, worry about using less code as it saves bandwidth and load time (but nothing you will most likely have to worry about as it is minimal unless you are dealing with capacities of millions of unique visitors each month.)
Last edited by SheSaidImaPregy; Oct 8th, 2007 at 11:07 am.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
Offline 1,080 posts
since Sep 2007