1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
Private Function SQL_Build_INSERT(ByVal Tablename As String, ByVal Felder As Array, ByVal Werte As Array) As String
Dim res As String = Nothing
If Tablename = Nothing Or Felder.Length = 0 Or Felder.Length <> Werte.Length Then
Throw New Exception("Tablename or Felder = NOTHING or Felder.Length <> Werte.Length")
End If
Dim ai As Integer = Felder.Length
Dim i As Integer
res = "INSERT INTO " & Tablename & " ("
For i = 0 To Felder.Length - 1
If i = 0 Then
res &= "`" & Felder(i).ToString & "`"
Else
res &= ", `" & Felder(i).ToString & "`"
End If
Next
res &= ") VALUES ("
For i = 0 To Werte.Length - 1
If i = 0 Then
If Werte(i).ToString = Nothing Then
res &= "NULL"
Else
res &= "'" & Felder(i).ToString & "'"
End If
Else
If Werte(i).ToString = Nothing Then
res &= ", NULL"
Else
res &= ", '" & Felder(i).ToString & "'"
End If
End If
Next
res &= ")"
Return res
End Function
|