我有一个数组像下面如何向所有数组项添加一些字符串?
(0) = "apple"
(1) = "orange"
我怎样才能一些字符串数组添加到所有的项目吗?像苹果成为 '苹果',橙色成为 '橙色'
编辑
Private Sub test()
Dim txtReader As TextReader = New StreamReader("data.csv")
Dim parser = New CsvParser(txtReader)
Dim str As String = ""
'Ignore first line
parser.Read()
While True
Dim row = parser.Read()
If row Is Nothing Then
Exit While
End If
str &= $"({String.Join(",", row)}),"
End While
str_record = str.TrimEnd(",")
End Sub
Private Sub Model_Insert()
Dim data As String = ""
Dim query As String = "INSERT INTO main_item(item_code,item_name,item_desc,item_unitprice,item_barcode,dept_id,cat_id,gst_id,set_item,active)" &
"VALUES " & str_record & ""
Using cmd = New MySqlCommand(query, conn)
cmd.ExecuteNonQuery()
End Using
End Sub
我试着去创建一个字符串,并用它在INSERT INTO
你可以尝试更清楚,因为它没有多大意义阵列通常像这样的工作:'点心水果( )As String = {“apple”,“orange”,“...”}' – Mederic
现在你已经完全修改了你的问题。阵列在哪里?你为什么不在第一时间发布你真正的问题? –
请不要这样做。使用参数化查询,不要使用字符串连接 – Pikoh