hi,
i am new to programming and database. please help
when ever i am submitting the i am getting the ERROR "Violation of PRIMARY KEY constraint 'PK_property'. Cannot insert duplicate key in object 'dbo.property'. The statement has been terminated."
every time when i insert new data. and if i am removing primery key records entering two in database. whats the problem?
you can check the code
Protected Sub btn_submit_Clic k(ByVal sender As Object, ByVal e As System.EventArg s) Handles btn_submit.Clic k
Try
Dim con As New SqlConnection
con.ConnectionS tring = "Data Source=72.18.12 9.86,1533;Initi al Catalog=rocklan d;Database=rock land;Uid=udi;pw d=pwd;"
con.Open()
Dim cmd As New SqlCommand
cmd.CommandText = "INSERT INTO property (...) VALUES ('" .... "')"
cmd.Connection = con
cmd.CommandType = CommandType.Tex t
cmd.ExecuteNonQ uery()
con.Close()
Label1.Visible = True
Label1.Text = "Submitted"
Catch ex As Exception
Label1.Text = ex.Message
End Try
End Sub
i am using sql server 2005
i am new to programming and database. please help
when ever i am submitting the i am getting the ERROR "Violation of PRIMARY KEY constraint 'PK_property'. Cannot insert duplicate key in object 'dbo.property'. The statement has been terminated."
every time when i insert new data. and if i am removing primery key records entering two in database. whats the problem?
you can check the code
Protected Sub btn_submit_Clic k(ByVal sender As Object, ByVal e As System.EventArg s) Handles btn_submit.Clic k
Try
Dim con As New SqlConnection
con.ConnectionS tring = "Data Source=72.18.12 9.86,1533;Initi al Catalog=rocklan d;Database=rock land;Uid=udi;pw d=pwd;"
con.Open()
Dim cmd As New SqlCommand
cmd.CommandText = "INSERT INTO property (...) VALUES ('" .... "')"
cmd.Connection = con
cmd.CommandType = CommandType.Tex t
cmd.ExecuteNonQ uery()
con.Close()
Label1.Visible = True
Label1.Text = "Submitted"
Catch ex As Exception
Label1.Text = ex.Message
End Try
End Sub
i am using sql server 2005
Comment