不存储在数据库中 [英] NOT storing in database

查看:123
本文介绍了不存储在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
       Dim Con As New SqlConnection
       Con.ConnectionString = "Data Source=12.18.1.77;Initial Catalog=ACC_FG;User ID=sa;Password=***********"
       Dim cmd As New SqlCommand
       Dim status As String
       Dim ra As Integer
       If (RadioButton1.Checked) Then
           status = "title"
       ElseIf (RadioButton2.Checked) Then
           status = "regular"
       Else
           status = ""

       End If
       Dim cost As String
       If (CheckEdit1.Checked) Then
           cost = "Branches"
       ElseIf (CheckEdit2.Checked) Then
           cost = "Departments"
       ElseIf (CheckEdit3.Checked) Then
           cost = "projects"
       ElseIf (CheckEdit4.Checked) Then
           cost = "cost centres"
       Else
           cost = ""
       End If

       Try
           Con.Open()

           cmd.Connection = Con

           cmd = New SqlCommand("insert into Accounts values ('" & TextEdit1.Text & "','" & TextEdit2.Text & "','" & TextEdit3.Text & "','" & TextEdit4.Text & "','" & TextEdit5.Text & "','" & TextEdit6.Text & "','" & TextEdit7.Text & "','" & status & "','" & LookUpEdit1.Text & "','" & LookUpEdit2.Text & "','" & cost & "')", Con)
           ra = cmd.ExecuteNonQuery()
           Con.Close()

           MsgBox("CATEGORY ADDED", MsgBoxStyle.Information, "RECORD ADDED=" & ra)


       Catch ex As Exception
           MsgBox("not added", MsgBoxStyle.Critical)

       End Try







它不存储在我的数据库

如何清除此错误




its not storing in my database
how can i clear this error

推荐答案

您认为您不应该定义目标字段吗?



Don't you think you should define destination fields?

INSERT INTO TableName (Field1, Field2, Field3)
VALUES('Value1', Value2, 'Value3')


在vb.net中需要目的地是必需的
is requred in vb.net that destination is required


这篇关于不存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆