我有一個數組像下面如何向所有數組項添加一些字符串?
(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