
Originally Posted by
o0OpurezO0o
Dude, why dont u fix the MSgbox thing? It is so long:
Code:
if msgboxresult.Yes then
[Your Code In Here]
end if
It is quite Simple.
@Jason, gj. Who thaught you this?
And for reading of a table you can do the following:
[php]Private reader as MySQLDataReader
'Let's say TxtSerial is the Textbox the user entrys the serial
'We have a table with the following structure:
' Serial | Used
'Used will hold either 0 or 1
Private Sub Validation
Dim strSQL as string = "SELECT * FROM Serials WHERE Serial='& cserial &' AND Used='0'" 'Serials = tablename
dim cserial as string = txtSerial.text
Try
dim cmd as new mysqlcommand(strSQL, SQLConnection)
reader = cmd.ExecuteReader
if not reader.hasrows
msgbox("The serial is either in use or does not exist.", msgboxstyle.information)
reader.close
else
reader.close
Dim strUsed as string = "UPDATE Serials SET Used='1' WHERE Serial='& curserial &'"
Dim Update as new mysqlcommand(strUsed, SQLConnection)
Update.ExecuteNonQuery
Msgbox("You have successfully registered the program.")
end if
Catch ex as MysqlException
reader.close
msgbox(ex.message.tostring)
end try
End Sub[/php]
You will have to add all your serials to the database before, mhmkay?
I suggest you make yourself a little application adding 100+ random serials into your program.
[php]
'the connection must be open ofc.
Dim i as integer
Do until i = 100
Dim strSQL as string = "INSERT INTO Serials(Serial, Used) VALUES('" & randomserial & "','0')"
Dim cmd as new mysqlcommand(strSQL,Sqlconnection)
cmd.executenonquery
i += 1
Loop
[/php]
Just make a sub to randomly create strings.
I just woke up and wrote it out of my mind, so there might be some errors =D.