注册 登录
编程论坛 VB.NET论坛

cmd.ExecuteNonQuery() 这个地方老是报错整么回事?

L483342650 发布于 2021-07-19 16:04, 1163 次点击
Imports System.Data.SqlClient
Public Class Form1
    Private Conne As SqlConnection = New SqlConnection("Data Source=SWPDM\SWPDM;Initial Catalog=master;Integrated Security=True")
    Private Sub adddate()
        Dim cmd As SqlCommand
        Dim cmdstring As String = ("insert CustomTemp(名称,规格,材料) value (" + CStr(TextBox1.Text) + ",'" + TextBox2.Text + ",'" + TextBox3.Text + ",")
        cmd = New SqlCommand(cmdstring, Conne)
        Conne.Open()
        cmd.ExecuteNonQuery()
        Conne.Close()


    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        adddate()


    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
    End Sub
End Class
2 回复
#2
apull2021-07-19 19:17
Dim cmdstring As String = ("insert into CustomTemp(名称,规格,材料) value ('" + CStr(TextBox1.Text) + "','" + TextBox2.Text + "','" + TextBox3.Text + "'")
#3
L4833426502021-07-20 13:46
非常感谢!
1