I'm trying to get my feet wet in ASP.net programming, as one of our companies applications is designed in it, and while I understand VB.net, ASP.net is a little strange to me. As a test, I've started working on a database driven web application that has a log in form. The log in form makes a call to an SQL database to see if the users name and PW exist in a table. If they do, it redirects them to the main form. SO far everything is working, but now I'd like to do a test by having the form write the current date/time back to the database to a field called "LastLogin" if their result was found.
What I have so far:
Partial Class Login
Inherits System.Web.UI.Page
Public Sub LogIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
Dim connStr As String = "Data Source=WHITE-DWARF;Initial Catalog=UserDatabase;Integrated Security=True"
Dim sqlconnet As Data.SqlClient.SqlConnection
Dim MyComm As Data.SqlClient.SqlCommand
sqlconnet = New Data.SqlClient.SqlConnection()
sqlconnet.ConnectionString = connStr
MyComm = New Data.SqlClient.SqlCommand("", sqlconnet)
MyComm.CommandType = Data.CommandType.Text
MyComm.CommandText = "SELECT * FROM Logins WHERE (UserName ='" & txtUserName.Text & "') AND (Password = '" & txtPassword.Text & "') "
sqlconnet.Open()
Dim result As Data.SqlClient.SqlDataReader = MyComm.ExecuteReader(Data.CommandBehavior.CloseConnection)
If result.HasRows = False Then
lblStatus.Text = "Username and/or Password does not exist!"
Else
Session("Username") = txtUserName.Text
Response.Redirect("success.aspx")
------> MyComm.CommandText = "UPDATE Logins SET LastLogin=" & Now & " WHERE (UserName ='" & txtUserName.Text & "') AND (Password = '" & txtPassword.Text & "')"
End If
result.Close()
End Sub
End Class
The text next to the "---->" is what I'm trying to have done back to the database, but not sure if I need to redeclare the whole SQL data connection again just to perform an UPDATE...is there an easier way than redeclaring everything?
I like Neowin a lot, but this "article" is shady and misleading.
We need an "editorial" flag and this isn't "news" it's "my cousin's dog's best friend posted on twitter about their snapchat account from their dog's owner that a bad thing happened, so it's NEWS."
Thanks
Burrrrn. Bought COD WWII last month when it was on sale for PC. Oh well. Excellent game tho, and the PC version plays/looks amazing (and has it's own PC achievements). ...wondering if this is a lesson on waiting on sales.
...also hoping Rise of the Tomb Raider has it's own PC Achievements
Google Chrome 137.0.7151.120 (offline installer) by Razvan Serea
The web browser is arguably the most important piece of software on your computer. You spend much of your time online inside a browser: when you search, chat, email, shop, bank, read the news, and watch videos online, you often do all this using a browser.
Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier. Use one box for everything--type in the address bar and get suggestions for both search and Web pages. Thumbnails of your top sites let you access your favorite pages instantly with lightning speed from any new tab. Desktop shortcuts allow you to launch your favorite Web apps straight from your desktop. Chrome has many useful features built in, including automatic full-page translation and access to thousands of apps, extensions, and themes from the Chrome Web Store.
Google Chrome is one of the best solutions for Internet browsing giving you high level of security, speed and great features. Important to know! The offline installer links do not include the automatic update feature. Google Chrome 137.0.7151.120 changelog:
[$7000][420697404] High CVE-2025-6191: Integer overflow in V8. Reported by Shaheen Fazim on 2025-05-27
[$4000][421471016] High CVE-2025-6192: Use after free in Profiler. Reported by Chaoyuan Peng (@ret2happy) on 2025-05-31
[425443272] Various fixes from internal audits, fuzzing and other initiatives
Download web installer: Google Chrome Web 32-bit | Google Chrome 64-bit | Freeware
Download: Google Chrome Offline Installer 64-bit | 128.0 MB
Download: Google Chrome Offline Installer 32-bit | 115.0 MB
Download page: Google Chrome Portable
Download: Google Chrome MSI Installers for Windows (automatic update)
View: Chrome Website | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
Recent Achievements
gatilogistic earned a badge One Month Later
Custom Greek Shirts earned a badge One Year In
Custom Greek Shirts earned a badge One Month Later
Question
SirEvan
I'm trying to get my feet wet in ASP.net programming, as one of our companies applications is designed in it, and while I understand VB.net, ASP.net is a little strange to me. As a test, I've started working on a database driven web application that has a log in form. The log in form makes a call to an SQL database to see if the users name and PW exist in a table. If they do, it redirects them to the main form. SO far everything is working, but now I'd like to do a test by having the form write the current date/time back to the database to a field called "LastLogin" if their result was found.
What I have so far:
The text next to the "---->" is what I'm trying to have done back to the database, but not sure if I need to redeclare the whole SQL data connection again just to perform an UPDATE...is there an easier way than redeclaring everything?
Link to comment
https://www.neowin.net/forum/topic/940030-aspnet-update-sql-datetime-field-upon-successful-login/Share on other sites
3 answers to this question
Recommended Posts