Primary Key checking
-
Hello All, I want to check a simple think in the database ie i want to check the particular data is already in the database or not. Particular table contain only one field and that field is only a primary key. i want to check it with my frond end that is visual studio.net 2008 I write the below code for that rs.Open("select * from CategoryMaster where categoryname = '"&txtcat.Text &"'", con, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic) If rs.EOF Then rs.AddNew() rs.Fields("CategoryName") = txtcat.Text rs.Update() txtcat.Text = "" txtcat.Focus() Else MsgBox("This category is Already in database ") End If I that code it shown some error in the below line rs.Fields("CategoryName") = txtcat.Text The error is Property 'Item' is 'ReadOnly' Please help me to resolve this :(( Thanks
-
Hello All, I want to check a simple think in the database ie i want to check the particular data is already in the database or not. Particular table contain only one field and that field is only a primary key. i want to check it with my frond end that is visual studio.net 2008 I write the below code for that rs.Open("select * from CategoryMaster where categoryname = '"&txtcat.Text &"'", con, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic) If rs.EOF Then rs.AddNew() rs.Fields("CategoryName") = txtcat.Text rs.Update() txtcat.Text = "" txtcat.Focus() Else MsgBox("This category is Already in database ") End If I that code it shown some error in the below line rs.Fields("CategoryName") = txtcat.Text The error is Property 'Item' is 'ReadOnly' Please help me to resolve this :(( Thanks
Try:
rs.Fields("CategoryName")**.Value** = txtcat.Text
. -
Try:
rs.Fields("CategoryName")**.Value** = txtcat.Text
.