Hi friends,
i want to restrict -ve values entering into access database table.im using vb.net as front end...
please help..

Recommended Answers

All 5 Replies

negative values I believe. He's used the electrical shorthand.
In your front end add a RangeValidator to the control where the numbers are entered and set the minimum value to 0.

how do i add validation rules in create table statement?please help

You use the validators at the client end, either the win form or the web page.
Say you have a textbox that the user enters a number in. You apply a RangeValidator to the textbox which, when the button to insert the data is clicked, checks the value in the textbox is within the specified range. If not,processing stops.
If you want to do the validation in the database you can set up check constraints on the column. Here is a sample table definition that restricts a column to positive numbers:

CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CHECK (P_Id>0)
)

Hope that helps,

Yeah got it bro..,thanks alot for ur help,god bless

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.