Click here to Skip to main content
15,888,802 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Dave Kreskowiak2-Mar-16 6:51
mveDave Kreskowiak2-Mar-16 6:51 
GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Real Corks2-Mar-16 7:41
Real Corks2-Mar-16 7:41 
GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Real Corks2-Mar-16 7:49
Real Corks2-Mar-16 7:49 
GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Dave Kreskowiak2-Mar-16 7:58
mveDave Kreskowiak2-Mar-16 7:58 
GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Real Corks2-Mar-16 8:15
Real Corks2-Mar-16 8:15 
GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Sascha Lefèvre2-Mar-16 8:46
professionalSascha Lefèvre2-Mar-16 8:46 
GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Real Corks2-Mar-16 11:40
Real Corks2-Mar-16 11:40 
AnswerRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Richard Deeming2-Mar-16 9:49
mveRichard Deeming2-Mar-16 9:49 
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

Also, don't store local variables as class-level fields. Declare them where you use them. And don't forget to wrap IDisposable objects in a Using block.

In this instance, there's no need to loop through the results of the query just to insert them into another table. Just use an INSERT .. SELECT statement[^]:
VB.NET
Dim query As String = "INSERT INTO tbl_studProspectus SELECT '', @StudentNumber, subjectcode, units, prereq, semester, year FROM tbl_subjects"

Using conn As New MySqlConnection("server=localhost;userid=root;password=;database=aes")
    Using cmd As New MySqlCommand(query, conn)
        cmd.Parameters.AddWithValue("@StudentNumber", textSNumber.Text)
        
        conn.Open()
        cmd.ExecuteNonQuery()
    End Using
End Using



Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Real Corks2-Mar-16 11:46
Real Corks2-Mar-16 11:46 
GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Real Corks2-Mar-16 11:52
Real Corks2-Mar-16 11:52 
GeneralRe: can someone help me to fix this in mysql vb "INVALID ATTEMP TO READ WHEN READER IS CLOSE "? Pin
Real Corks2-Mar-16 12:45
Real Corks2-Mar-16 12:45 
QuestionExcel VBA For Loop Weighted Average Pin
Member 1226553729-Feb-16 22:40
Member 1226553729-Feb-16 22:40 
AnswerRe: Excel VBA For Loop Weighted Average Pin
Kenneth Haugland29-Feb-16 23:50
mvaKenneth Haugland29-Feb-16 23:50 
GeneralRe: Excel VBA For Loop Weighted Average Pin
Member 122655371-Mar-16 0:27
Member 122655371-Mar-16 0:27 
GeneralRe: Excel VBA For Loop Weighted Average Pin
Kenneth Haugland1-Mar-16 11:13
mvaKenneth Haugland1-Mar-16 11:13 
QuestionNet.Sockets.TcpListener Pin
hansoctantan29-Feb-16 1:40
professionalhansoctantan29-Feb-16 1:40 
QuestionRe: Net.Sockets.TcpListener Pin
Eddy Vluggen29-Feb-16 2:41
professionalEddy Vluggen29-Feb-16 2:41 
AnswerRe: Net.Sockets.TcpListener Pin
Dave Kreskowiak29-Feb-16 3:55
mveDave Kreskowiak29-Feb-16 3:55 
Questionjson exception Pin
duup27-Feb-16 0:43
duup27-Feb-16 0:43 
AnswerRe: json exception Pin
Dave Kreskowiak27-Feb-16 10:49
mveDave Kreskowiak27-Feb-16 10:49 
GeneralRe: json exception Pin
duup28-Feb-16 21:04
duup28-Feb-16 21:04 
GeneralRe: json exception Pin
Dave Kreskowiak29-Feb-16 2:41
mveDave Kreskowiak29-Feb-16 2:41 
Questionhow to start a vbs script in a vbs script on a client computer Pin
Member 1191673523-Feb-16 22:31
Member 1191673523-Feb-16 22:31 
AnswerRe: how to start a vbs script in a vbs script on a client computer Pin
Dave Kreskowiak24-Feb-16 2:16
mveDave Kreskowiak24-Feb-16 2:16 
GeneralRe: how to start a vbs script in a vbs script on a client computer Pin
Member 1191673524-Feb-16 3:39
Member 1191673524-Feb-16 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.