mercredi 1 avril 2015

How to make an INSERT QUERY String using an array of variables

My code is:



For index = 0 To dupColIndx - 1
expression(index) = dgvINSRT.Rows.Item(i).Cells.Item(index).Value.ToString
Next

Dim strInsrt As String = "INSERT INTO " & _
dbTbl & _
colStr & _
Strings.Replace(expression(0), "'", "''", 1, -1, CompareMethod.Binary) & "','" & _
Strings.Replace(expression(1), "'", "''", 1, -1, CompareMethod.Binary) & "','" & _
Strings.Replace(expression(2), "'", "''", 1, -1, CompareMethod.Binary) & "')"


In the code above instead of entering manually expression(0), expression(1), etc. I want the string to be concatenated automatically once I enter the value of 'n' for expression(n).


Thanks.


Aucun commentaire:

Enregistrer un commentaire