Smurfsdabomb
Member
- Joined
- Jan 10, 2009
- Messages
- 10
- Programming Experience
- 1-3
What I want to do is retrieve data from my database using an SQL query (which I can do perfectly) and then manipulate it. Specifically I've got a unique identifier field and I want to get the highest previous entry and increment it by one with this SQL statement
And no problems with the SQL as it is, the problem is with the first line in the code as NextID is an integer being assigned to a string, and it needs to be an integer so I can increment it.
Is there any way to convert a string to an integer or alternatively to return an integer from an SQL statement?
Thanks!
VB.NET:
NextID = "Select ID from League where ID = (select max(ID) from League);"
NextID = NextID + 1
aQuery = "INSERT INTO League"
aQuery = aQuery & " VALUES(" & NextID & ",'" & LeagueOwner & "','" & LeagueName & "','" & LeagueDescription & "')"
aCommand = New Data.OleDb.OleDbCommand(aQuery, aConnection1)
aCommand.ExecuteNonQuery()
aConnection1.Close()
And no problems with the SQL as it is, the problem is with the first line in the code as NextID is an integer being assigned to a string, and it needs to be an integer so I can increment it.
Is there any way to convert a string to an integer or alternatively to return an integer from an SQL statement?
Thanks!