Monday, March 19, 2012

how can i make checkbox

hello all i have a 2 questions hope that u can help me my first question is: in ms access there was a data type named yes/no and it was a checkbox is there a checkbox data type in sql server 2005?

my second question is i need the connection code between asp.net 2005 and sql server 2005 i searched in here for that code but i got more confuse i found two codes and both are not working so hope u can give me the right connecting code. that's all thanks

Thebitdata Type is the equivelent to ths Yes/No data type.

If you mean the connection string, it is like this for SQL Server 2005:

server=<ServerAddress>;uid=<userId>;password=<password>;database=<databaseName>

Of course, fill in the bold to the actual values. Also, heres a good website if you ever need any connection strings:

http://www.connectionstrings.com/

|||

hellojavanthanks for ur reply i tried the bit data type but no checkbox appeared and i tried to write yes but it didnt accept that value so plase hope u tell me what i shoud do? and as for the connection string i dont mean that string but i mean the main connection string for example in vs2003 when i want to connect to a database that's what i should do:

Dim conn as newsqlconnection (the string u wrote is here)

the bold statment that what i want to know? thanks for ur reply again

|||no one can help?!!!!!|||

Datatypes are not restricted to a specific UI control that can display it like in Access. Some applications that use a grid-like or form-like interface to allow you to enter values into a table will display a checkbox for a column that is defined as bit (or bit not nullable), while some others will display it as it's raw value of 0 or 1. Depends on the tool.

In ASP.NET, you have the option of displaying it to the end user any way you want. I believe the form wizards by default will make a checkbox out of it, and some datagrids will as well, I am unsure of what the built in datagrid will do, I'd guess mostly a textbox with 0 or 1 in it. The gridview might be more intelligent than that, but I wouldn't bet on it either.

The bit datatype is the closest match, but you could also make a column of char(1) and store "Y"/"N" in it and use a checkbox to display it to the end user, but I know of no tools that will automatically turn that into a checkbox for you. You could also make it a varchar(3) and store "yes"/"no" in it as well, and optionally put a check constraint to make sure only the values "yes"/"no" or "Y"/"N" are able to be stored in there.

|||helloMotleythanks for ur reply and as u said there as an option in the gridview allow me to delete and select and edit in the properties box but i have another problem when i get to delete a record i have an error said that deleting is not supported by data source i serched for that error and i knew that the solution is when i configuring my data source in the data source wizard i have to click on advanced sql generation option that let me check two choices to enable insert and deleting and update the problem is that two choices are not active i dont know why so please if u can help me then i'm waiting thanks for u all.|||Sorry, I was away in Florida and couldn't check my emails. The bit data type is actually a 0 or 1 value. It is the closest thing you can get to Yes/No in Sql Server. You have to check the value of your checkbox and insert the proper data type based on that. I wouldnt recommend doing a char(1) because that is not a true yes/no type field.|||hello again javan thanks for ur care about reply but i have a little problem as i said in my last post that advanced option button is not active so i hope u can really help cos i really need that option thanks for u all.|||Yes,... I found this problem in the SQL DataSource too before. It seems that once the datasource is created then the option is not available when you go to edit it. What you have to do is delete and then recreate the datasource and make sure you press the advanced options on the first try. The check the "Generate Insert/Edit/Delete" checkbox.|||hello JAVAN thanks for ur reply i did as u said but no use problem still exist anyway i sent u private msg hope u reply it thanks again.|||

The "Generate Insert,Update,etc..." checkbox may not be visible if you are not returning a Primary Key field from the database or if you do not have one defined. You must return a PRimary Key field from the select statement for the SQL DataSource to be able to update the records.

|||

hello dear javan

i have that problem(update&.. checkboxes) for about 6 days but ur answers help me tp solve it.

so thanks for ever

be lucky and successful like always

No comments:

Post a Comment