纽约没举办过奥运会:在asp.net vb.net语言中添加到数据库SQL主键重复怎么添加

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 17:00:55
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim myconnection As SqlConnection = New SqlConnection("server=(local);uid=sa;password=;database=项目申报管理系统")
Dim sql As String
sql = "insert into taskbook 数据库中表名称(tbno,titleno,tbsendtime,tbcontent)" _ 添加到表中的列
& "values('" & TextBox1.Text.Trim() & "','" & TextBox2.Text.Trim() & "','" & TextBox4.Text.Trim() & "','" & TextBox3.Text.Trim() & "')"
Dim mycommand As SqlCommand = New SqlCommand(sql, myconnection)

If TextBox2.Text = "" Then
message.Text = "带*不能为空!!"
ElseIf TextBox1.Text = "" Or TextBox3.Text = "" Then
message.Text = "填加失败!!"

Else
myconnection.Open()
mycommand.ExecuteNonQuery()
myconnection.Close()
message.Text = "填加成功!!"
End If

End Sub

不会的上百度搜,顺便拿点分