Showing posts with label entry. Show all posts
Showing posts with label entry. Show all posts

Tuesday, March 27, 2012

Boolean Data Type not available (workaround for checkbox.checked storing?)

I have a page for inventory price entry that I have used for a while. Now I need to add a checkbox for whether or not the price includes shipping. I added the checkbox to the form and had it posting 'True' or 'False' to the database as nchar(10) data type. When the gridview pulls up the data, I have the Item Template like this, so it shows a disabled checkbox either checked or not:

<asp:CheckBoxID="CheckBox2"runat="server"Checked='<%# Convert.ToBoolean(Eval("Shipping")) %>'Enabled="False"/>

This works fine for displaying the values, but I copied the checkbox to the Edit Item Template, but did not disabled this one. At first, I didn't change the databindings, leaving it Convert.ToBoolean(Eval("Shipping")), which allowed me to go into Edit mode, change the checkbox, then click update. At which point it would return to it's original state (meaning Update wasn't actually updating). However if I change the databindings, then the page won't display.

I checked the SQL statement, and sure enough, it has the

UpdateCommand="UPDATE [PartsTable] ... SET [Shipping] = @.Shipping... WHERE [PartID] = @.original_PartID

After fiddling with the sql statement, now I get Object cannot be cast from DBNull to other types. I think that means that the checkbox is sending a null value to the database.

Any insight as to how to get this to work is much appreciated. Thanks in advance.

I don't know if this will work declaratively but your problem is ANSI SQL Boolean is three valued True/False/Null the reason ANSI SQL is called three valued logic. The links below will show how to use Nullable types of FCL(framework class library) 2.0 to solve your problem. Hope this helps.

http://www.codeproject.com/csharp/c__20_nullable_types.asp

http://www.c-sharpcorner.com/UploadFile/PashuSX/NullableTypes04282006114548AM/NullableTypes.aspx?ArticleID=b28a5114-a92a-4ced-a23c-06d8a29de6e4

|||

I found this thread:http://forums.asp.net/thread/1092916.aspx and after reading it, I've changed the data type in the database to Bit. This has significantly helped my problem .

BUT I have the checkbox in normal mode displaying perfectly fine. However, when I click edit, there is a textbox that displays either True or False (True is 1 and False is 0 in the database). If I change True to 0 or False to 1, it works. HOWEVER I want it to display a textbox. When I delete the textbox in the edit template, replace it with a checkbox and then set the databinding to the shipping field, I can click edit and the box appears just fine, but when I change it and click update, I get this Error:Syntax error converting the nvarchar value 'False' to a column of data type bit.Which to me means that it is trying to post the checkbox.checked ='s value, not just checkbox.checked which is stored as a bit in the database.

How/Where can I change this?

|||Figured it out! Turns out the auto generated update statement set the paramenter to

<asp:ParameterName="Shipping"Type="String"/>

So I took out the Type="String" and it fixed my problem.

Thanks.

|||I am glad to see your problem is resolved.

Boolean ? in SQL (2005) table

I was wondering what should be used for a yes/no/ entry identifier . Should it be a simple int , tinyint , or uniqueidentifier?

Thank you

The bit data type is for values that can be either 0 or 1, such as No/Yes or False/True.|||The way you have written your answer suggests that 0 =yes and 1 = no which goes against my common sence. Could you clarify. I am sorry if this seams a bit picky.|||

No problem:

0 --> No, False

1 --> Yes, True

Boolean ? in SQL (2005) table

I was wondering what should be used for a yes/no/ entry identifier . Should it be a simple int , tinyint , or uniqueidentifier?

Thank you

The bit data type is for values that can be either 0 or 1, such as No/Yes or False/True.|||The way you have written your answer suggests that 0 =yes and 1 = no which goes against my common sence. Could you clarify. I am sorry if this seams a bit picky.|||

No problem:

0 --> No, False

1 --> Yes, True

sql

Sunday, February 12, 2012

bizarre job behavior

Look in the 'sysjobs' table of the msdb database. See if
the there is an entry for the jobs. If there is, check
the 'originating_server' column. It may still have the old
server name in it......

>--Original Message--
>Over the weekend I transferred our non Clustered SQL
Server to a new
>Clustered environment. I moved the jobs by method of
scripting. Since then,
>serveral of my jobs have been failing with different
problems. The one thing
>all of these jobs have in common is that they all call
DTS Packages that
>read/ write to files. (.txt, .xls, etc.)
>For the record, the account that the SQL Agent runs in
has full control over
>these files. If I log directly onto the console with this
account, I can
>create/ edit/ drop anything I want.
>Another fun fact is that I can run all of these DTS
Packages manually.
>Now here is all of the problems I'm having with these
jobs.
>1. Access denied for the account that SQL runs in to
read/ write to the
>file.
>2. I start the job manually, it never runs. RClick/ Start
Job... nothing
>ever happens.
>3. Although the job has a schedule, it shows (Date and
time are not
>available.) under the Next Run Date column.
>4. Jobs have a staus of "Performing completion actions"
forever. I found
>this one in KB, but think its really a by product of the
other issues.
>Something is obviously very wrong here. Any ideas are
greatly appreciated.
>
>--
>SQL2K SP3
>TIA, ChrisR
>
>.
>No, it has the correct server name since I scripted/ created the jobs
instead of moving them.
"Coskun" <anonymous@.discussions.microsoft.com> wrote in message
news:157b01c51ab8$685e91e0$a601280a@.phx.gbl...[vbcol=seagreen]
> Look in the 'sysjobs' table of the msdb database. See if
> the there is an entry for the jobs. If there is, check
> the 'originating_server' column. It may still have the old
> server name in it......
>
> Server to a new
> scripting. Since then,
> problems. The one thing
> DTS Packages that
> has full control over
> account, I can
> Packages manually.
> jobs.
> read/ write to the
> Job... nothing
> time are not
> forever. I found
> other issues.
> greatly appreciated.

bizarre job behavior

Look in the 'sysjobs' table of the msdb database. See if
the there is an entry for the jobs. If there is, check
the 'originating_server' column. It may still have the old
server name in it......

>--Original Message--
>Over the weekend I transferred our non Clustered SQL
Server to a new
>Clustered environment. I moved the jobs by method of
scripting. Since then,
>serveral of my jobs have been failing with different
problems. The one thing
>all of these jobs have in common is that they all call
DTS Packages that
>read/ write to files. (.txt, .xls, etc.)
>For the record, the account that the SQL Agent runs in
has full control over
>these files. If I log directly onto the console with this
account, I can
>create/ edit/ drop anything I want.
>Another fun fact is that I can run all of these DTS
Packages manually.
>Now here is all of the problems I'm having with these
jobs.
>1. Access denied for the account that SQL runs in to
read/ write to the
>file.
>2. I start the job manually, it never runs. RClick/ Start
Job... nothing
>ever happens.
>3. Although the job has a schedule, it shows (Date and
time are not
>available.) under the Next Run Date column.
>4. Jobs have a staus of "Performing completion actions"
forever. I found
>this one in KB, but think its really a by product of the
other issues.
>Something is obviously very wrong here. Any ideas are
greatly appreciated.
>
>--
>SQL2K SP3
>TIA, ChrisR
>
>.
>
No, it has the correct server name since I scripted/ created the jobs
instead of moving them.
"Coskun" <anonymous@.discussions.microsoft.com> wrote in message
news:157b01c51ab8$685e91e0$a601280a@.phx.gbl...[vbcol=seagreen]
> Look in the 'sysjobs' table of the msdb database. See if
> the there is an entry for the jobs. If there is, check
> the 'originating_server' column. It may still have the old
> server name in it......
>
> Server to a new
> scripting. Since then,
> problems. The one thing
> DTS Packages that
> has full control over
> account, I can
> Packages manually.
> jobs.
> read/ write to the
> Job... nothing
> time are not
> forever. I found
> other issues.
> greatly appreciated.