Soldato
- Joined
- 20 Jan 2005
- Posts
- 2,722
- Location
- Whitley Bay
Hi there,
I have a numeric column in my SQL Express 2005 database intended to log the number of times someone has logged in to the database.
I'm trying to work out how to increase this value by one when someone logs into my (VB.NET) application.
I've got the code below set to run when they click login but it's blatantly rubbish so if anyone could help that'd be great!
Dim connString As String = "Server=" + ServerName + "\SQLEXPRESS;Database=login;UID=user;PWD=password"
Dim myConn As New SqlConnection(connString)
Dim commstr As String = "SELECT logins FROM usernames WHERE user_id = '" + RemUser + "'"
Dim mycommand As New SqlCommand(commstr, myConn)
myConn.Open()
Dim myReader As SqlDataReader = mycommand.ExecuteReader()
Dim value As Integer = CInt(myReader("logins"))
Dim value2 As Integer
value2 = (value + 1)
Dim mycommand2 As New SqlCommand("UPDATE usernames SET logins = '" + value2 + "' WHERE user_id = '" + RemUser + "'", myConn)
mycommand2.ExecuteNonQuery()
myconn.close()
TIA
Si

I have a numeric column in my SQL Express 2005 database intended to log the number of times someone has logged in to the database.
I'm trying to work out how to increase this value by one when someone logs into my (VB.NET) application.
I've got the code below set to run when they click login but it's blatantly rubbish so if anyone could help that'd be great!
Dim connString As String = "Server=" + ServerName + "\SQLEXPRESS;Database=login;UID=user;PWD=password"
Dim myConn As New SqlConnection(connString)
Dim commstr As String = "SELECT logins FROM usernames WHERE user_id = '" + RemUser + "'"
Dim mycommand As New SqlCommand(commstr, myConn)
myConn.Open()
Dim myReader As SqlDataReader = mycommand.ExecuteReader()
Dim value As Integer = CInt(myReader("logins"))
Dim value2 As Integer
value2 = (value + 1)
Dim mycommand2 As New SqlCommand("UPDATE usernames SET logins = '" + value2 + "' WHERE user_id = '" + RemUser + "'", myConn)
mycommand2.ExecuteNonQuery()
myconn.close()
TIA
Si
