我收到以下錯誤:錯誤保存到數據庫的組合框
error : you have an error in your sql syntax.check the manual that corresponds to your mysql server version for the right syntax to use near 'SOFTWARE DEVELOPER' at line 1.
這是我的代碼:
Imports MySql.Data.MySqlClient
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conStr As String = ("server=localhost;username=root;password=rootfnc;database=one")
Try
Dim con As New MySqlConnection(conStr)
Dim cmd As MySqlCommand
For i = 0 To ComboBox1.Items.Count
con.Open()
Dim sqls As String
sqls = "insert into one.initial_nom (idinitial_nom, f_name, s_name, th_name, fo_name, app_no, adm_type) values ('" & TextBox6.Text & "','" & TextBox1.Text & "', '" & TextBox2.Text & "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & TextBox5.Text & ",'" & ComboBox1.Items(i).ToString & "')"
cmd = New MySqlCommand(sqls, con)
cmd.ExecuteNonQuery()
Next
Catch ex As Exception
MsgBox("Error in saving to Database. Error is :" & ex.Message)
End Try
End Sub
有誰知道錯誤是怎麼引起的?
請提供更多詳細信息。你什麼時候收到錯誤?你想做什麼?? – Blunderfest
我想添加一些記錄與組合box.when我點擊保存按鈕...錯誤:你有一個錯誤在你的SQL syntax.check手冊,對應於你的mysql服務器版本的正確語法使用附近' SOFTWARE DEVELOPER'在第1行。 – user3795891
在您的物品計數中,Items.Count-1 – Codexer