Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 EXECUTE INSERT + CHECK CONSTRAINT

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-02-04 : 07:23:02
writes "HI,

I TRIED TO INSERT VALUE USING VB TO COLOUM THAT HAVE CHECK CONSTRAIN
IN THE TABEL DISSINE .

THE DATABAS IS SQL 7.

THE CODE IS:Public stud_conn As New ADODB.Connection
Public stud_rs As New ADODB.Recordset

Private Sub Command1_Click()
stud_conn.Close
End Sub

Private Sub Command2_Click()
Dim a As String
a = Trim(Text2.Text)
stud_conn.Execute "insert into stud_info(city)values (' " & a & " ')"
End Sub

Private Sub Form_Load()
stud_conn.Open "Provider=SQLOLEDB.1;Persist Security Info=false;" _
& "User ID=einat;Initial Catalog=STUD_2;Data Source=oemcomputer"
If stud_conn.State = adStateOpen Then

L1.Caption = "WWELL CONN"

Else
L1.Caption = "NO CONN"
End If
End Sub

THE ERROR MESSEGE IS:
RUNTIME ERROR -2147217900(80040E14)
INSERT STAEMENT CONFICTED WITH TABLE CHECK CONSTRAINT
'CK_STUD_INFO'






WHERE IS MY MISTAK??
THANKS
EINAT "

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2003-02-04 : 07:30:28
You can get the definition for the checkconstraint with this select

select * from information_schema.check_constraints
where constraint_name = 'CK_STUD_INFO'

Check the value in a so it does not violate the constraint.

Go to Top of Page
   

- Advertisement -