March 30, 2007 at 7:27 pm
If a column is datatype bit in SQL database, how can I represent it in the form? If I use drop down menu with Yes and No (1/0) VB boolean datatype, how can I convert form boolean output to bit so I can submit it to SQL database?
April 1, 2007 at 9:09 am
It depends on what version of Asp.net you are using in Asp.net 2.0 it is easy because of the introduction of the Nullable <T> because it also takes boolean, it is very hard in 1.1. Try the link below for Nullable solutions including the bool. Hope this helps.
http://www.codeproject.com/cs/database/NullableReaders.asp
Kind regards,
Gift Peddie
April 1, 2007 at 6:24 pm
Thank you GIft Peddie, I will go read now. How come you know everything?
April 2, 2007 at 2:18 am
Actually the VB6 boolean is True = -1 and False = 0, so to convert the myVB6Bool variable to SQL bit would be Abs(myVB6bool), which returns 1 or 0 instead of -1 or 0.
Andy
April 2, 2007 at 5:56 am
You are talking about obsolete stuff we are talking about VB.NET which in 1.1 was two valued so getting database Bool which is Bit is not easy but we asked for and got the Nullable<T> in the whole .NET framework in 2.0 to use with three valued database types.
Kind regards,
Gift Peddie
April 2, 2007 at 9:42 am
This is all too smart for me, like a rocket science. I am still a script kitty.
Problem is: there is bit field in the database allowOrders (this is not my field, I would make it bolean instead of bit). I need to control this field from the interface where I have a drop down menu allow_orders with values 1 and 0. I get the output from this menu and put it into the bolean variable allowOrders and try to update allowOrders field in the database with the value of this variable. And nothing happens. I assume it's because of the datatype discrepancy. My question was how I can convert that VB.NEt bolean variable into bit type so I can update bit field in SQL database?
April 2, 2007 at 10:54 am
Sorry in VB.NET 2.0 here is a visual way to do it with ObjectDatasource, let me know how it goes. Hope this helps.
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/objectdatasource.aspx
Kind regards,
Gift Peddie
April 3, 2007 at 3:27 pm
Peddie,
I just did a horrible thing and I don't know how to fix it. In IIS I was trying to add a new web app to application pool and I screwed everything. There was existing application that used permissions. New application also had users with permissions. When I started to add a website to default website, new application swallowed existing one, they both got into the same directory in IIS though phisically they are in the different ones. Then my colleque said "delete everything" from that web site directory in IIS and I did.
Now i need to restore everything. Fist time I did it, it took me several days and I don't remember how I did it, somebody told me how to add application to web site and to application pool in IIS. Now I am screwed again.
April 3, 2007 at 3:52 pm
Check your recycle bin if you can undelete the files there are undelete utilities test drive some and if you have source control the Admin can rollback your changes. Another place to check is the folders you created for the projects see if you can move it to VS, I don't know about regular VS because we use fancy Team Suite, it creates more work for you but you cannot make such mistakes with it. Keep me posted.
Kind regards,
Gift Peddie
April 3, 2007 at 4:12 pm
We don't have air conditioner for the whole day at work, high temp and no oxigen. It probably affected my brain. Thing is that when I added that ap, it added itself instead of Default web site and after I deleted it, default web site is gone. Now probably I have to re-install IIS since default web site folder should be always there. There is no source control. They just gave me server at work, I asked "who's server admin?" - "You are". "Who's db admin?" "You are". But I'm also a developer and it's hard to know and remember everything plus they want you to do support for other systems and impossible just to concentrate on one thing. I will go check the recycler bin though it will not help.
April 3, 2007 at 5:46 pm
I told you the recycle bin because it saved me about two weeks ago, I had to remove a feature the customer did not want, I knew some DLL needs to be deleted but it also broke my code I restored from the recycle bin got another needed DLL from someone down the hallway and my code compiled so when the Admins come calling I told them my current code is running so they rolled back the offending code and mark the rest hidden because I had all they needed to recreate what I removed. So check your recycled bin and get some undelete utilities but since you are the Admin get some removable drive so you will always have many copies of your running code. Hope this helps.
Kind regards,
Gift Peddie
April 4, 2007 at 1:02 pm
I restored everything on IIS this morning . But airconditioner is still not working for the second day, no oxigen and windows are sealed.
Now I am fighting DB again. I created a table
CREATE TABLE [dbo].[myTable](
[column1] [numeric](18, 0) NOT NULL,
[column2] [numeric](18, 0) NOT NULL,
CONSTRAINT [PK_myTable] PRIMARY KEY CLUSTERED
(
[column1] ASC,
[column2] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
After that I was asked to add one more column [column3] [datetime] NOT NULL. Combination of all three columns should be unique. I want to add that column3 to the primary key but don't know how to do it after table was already created. The only way is to drop the table and recreate it again with three columns in the constraint. But table has data already, I don't want to drop it. I already deleted something yesterday and it was not a happy thing...
April 4, 2007 at 1:32 pm
In Managemment Studio you can use the GUI to delete the constraint and add it later although I don't understand why you are making the primary key a composite. I would think it would be better to leave denormalization to when you create indexes, make sure you have backup before you make any changes so you can restore from Backup as needed. Hope this helps.
Kind regards,
Gift Peddie
April 4, 2007 at 1:35 pm
I would just call all three fields as foreign keys. But this is not my table but some other guy's and there is existing ap working with it and he doesn't let me change it, only to add to it. I am writing admin piece for his web ap. I just have no choice. Thanks!
April 4, 2007 at 2:51 pm
A primary key is a constraint you cannot add to it unless you drop your existing constraint and add a new one, that is the reason I told you to delete it which is the option in my Management Studio and create a new one. The other option is to create your column and add a unique constraint with all three columns try it may work. Hope this helps.
Kind regards,
Gift Peddie
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply