Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
cn = New SqlConnection
cn.ConnectionString = "Data Source=LAPTOP-VLPOS8UG;Initial Catalog=FAMS;Integrated Security=True"
Try
cn.Open()
Dim query As String
query = "INSERT INTO Master (Asset ID, Asset Category, Department, Brand/Make, Product Serial No, Purchase Date, Purchase Order Date, Installation Date, Purchase Cost, Depriciation Rate, Vendor Code, Warranty Details, Processor, RAM, HDD, Operating System, Application/Software, Note, Asset Name, Status)" + "VALUES ('" & Asset_IDTextBox.Text & "','" & Asset_CategoryComboBox.Text & "','" & DepartmentComboBox.Text & "','" & Brand_MakeTextBox.Text & "','" & Product_Serial_NoTextBox.Text & "','" & Purchase_DateDateTimePicker.Text & "','" & Purchase_Order_DateDateTimePicker.Text & "','" & Installation_DateDateTimePicker.Text & "','" & Purchase_CostTextBox.Text & "','" & Depriciation_RateTextBox.Text & "','" & Vendor_CodeComboBox.Text & "','" & Warranty_DetailsComboBox.Text & "','" & ProcessorComboBox.Text & "','" & RAMComboBox.Text & "','" & HDDComboBox.Text & "','" & Operating_SystemComboBox.Text & "','" & Application_SodtwareTextBox.Text & "','" & NoteTextBox.Text & "','" & Asset_NameTextBox.Text & "','" & StatusComboBox.Text & "')"
cmd = New SqlCommand(query, cn)
dr = cmd.ExecuteReader
MessageBox.Show("Data Saved")
cn.Close()
Catch ex As SqlException
MessageBox.Show(ex.Message)
Finally
cn.Dispose()
End Try
End Sub
答案 0 :(得分:0)
由于您使用ssms标记了问题,我认为您的RDBMS是SQL Server。
您的表中有多个列名称的空格;尝试在包含空格的列名称周围使用方括号:
query = "INSERT INTO Master ([Asset ID], [Asset Category],...