Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Thursday, March 29, 2012

Does SQL substitute float = 0 with DBNull.Value?

Hi
I have only been coding in .Net for about six months, and am not sure if this is a C# problem or an SQL one. I use the Data Access Application Block in my program.

I have two optional fields on my form (RangeFrom and RangeTo). If the user chooses not to enter data into these textboxes(textbox = ""), an entry on the db is created with null values. It works.

But sometimes the user wants to enter 0 as either an upper or lower end of a range. This is where my problem comes in. My program saves 0 as null too.

In my program I do a test on the textboxes and populate two float values in a business object (objQuestion) accordingly, like this:


if (txtrangefrom.Text != "") {
objQuestion.RangeFrom=float.Parse(txtrangefrom.Text);
objQuestion.RangeTo=float.Parse(txtrangeto.Text);
}
else {
objQuestion.RangeFrom=Convert.ToSingle(null);
objQuestion.RangeTo=Convert.ToSingle(null);
}

And this is what my Business object look like. It sets up the parameters and calls the Data Access Application Block to create an entry in my table:


// fieldslist
float cvintRangeFrom;
float cvintRangeTo;

//properties
public float RangeFrom {
get {
return cvintRangeFrom;
}
set {
cvintRangeFrom = value;
}
}

public float RangeTo {
get {
return cvintRangeTo;
}
set {
cvintRangeTo = value;
}
}

// some code deleted for readability...

public int AddOption() {
string cvstrSpName = "addOption";
SqlParameter [] cvstrStoredParams = SqlHelperParameterCache.GetSpParameterSet(gcstrConnectionString, cvstrSpName, true);
//lines deleted for readability...
//check if the optional fields have a value associated with them. if not, assign dbnull.value.
cvstrStoredParams[4].Value=(cvintRangeFrom != Convert.ToSingle(null) ? cvintRangeFrom : (object)DBNull.Value);
cvstrStoredParams[5].Value=(cvintRangeTo != Convert.ToSingle(null) ? cvintRangeTo : (object)DBNull.Value);
//lines deleted for readability...
SqlHelper.ExecuteNonQuery(gcstrConnectionString, CommandType.StoredProcedure, cvstrSpName, cvstrStoredParams);
return(cvintOptionID = Convert.ToInt32(cvstrStoredParams[0].Value));
}

I use Convert.ToSingle when working with nulls (or possible nulls) because I get an error when I use float.parse for this.

The thing is, after this method AddOption has been executed, I test the value if the business object's rangefrom (that is where I entered 0) and display it on my form. I still shows a 0, but on my database table it is null!


objQuestion.AddOption();
//txtrangefrom.Text=""; on the next line I test the value in the business object...
txtrangefrom.Text=objQuestion.RangeFrom.ToString(); // and this displays 0!!!
//txtrangeto.Text="";
txtrangeto.Text=objQuestion.RangeTo.ToString();

So to me it seems the problem seems to be either the DAAB or on the SQL side, but hopefully somebody can prove me wrong! I was thinking that it could also be float.parse/Convert.ToSingle methods and have done various tests, but I am none the wiser...
Any help or ideas will be greatly appreciated...I had this same problem with a VB project.

Just change the value of the floats to something that is not within the valid range (-1 or something) instead of null. It's not pretty or elegant, but it's better than fiddling with nulls ;)

SQLServer (I think) does implicitly convert 0 to null in some occasions, but I don't know the full details.

HTH|||You're right, it's not pretty, but I'll give it a go.
Thanks.

Wednesday, March 7, 2012

Does anyone know of a web based SQL Query tool?

Hi

I want to be able t give my users access to our SQL server database via a eb application published o our web server. I have found one freeware tool but it only supports SQL Server 2000 and the developer doesn't returns any emails.

Has anyone come across a web ui SQL query tool either freeware or one that can be purhcase

thanks for your help

Marcus

Do you just want to have a tool sending out a query from a textbox and getting the results back in a grid or something ? Or do you want tome graphical designer for your users ?

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

search for

SQL Server Web Data Administrator

on microsoft website

|||

Here is the link to SQL Server Web Data Administrator

http://www.microsoft.com/downloads/details.aspx?FamilyID=C039A798-C57A-419E-ACBC-2A332CB7F959&displaylang=en

Sethu Srinivasan, Software Design Engineer, SQL Server Manageability
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.

|||ASP Enterprise Manager http://sourceforge.net/projects/asp-ent-man/

Friday, February 24, 2012

Does a tool like this exist?

Hi:
I am looking for a tool/utility that can compare 2 tables (indexes and
constraints etc.) and create a SQL script containing 'ALTER TABLE ...'
statements that would update the second table so it is the same as the first
table.
Does anything like this exist? It's a bit of a long-shot isn't it?
TIA,
MartinH.
Red Gate has a tool called SQL Compare
http://www.red-gate.com/
--Keith
"Martin Hart - Memory Soft, S.L." <memorysoftsl _at_ infotelecom _dot_ es>
wrote in message news:O8IXekOQFHA.244@.TK2MSFTNGP12.phx.gbl...
> Hi:
> I am looking for a tool/utility that can compare 2 tables (indexes and
> constraints etc.) and create a SQL script containing 'ALTER TABLE ...'
> statements that would update the second table so it is the same as the
> first table.
> Does anything like this exist? It's a bit of a long-shot isn't it?
> TIA,
> MartinH.
>
|||Hi,
SQLCompare is an excellent tool to compare and generate the script for the
differences between databases.
Try out the 14 day trial.
http://www.red-gate.com/SQL_Compare.htm
Thanks
Hari
SQL Server MVP
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message
news:%23ux6lzOQFHA.3928@.TK2MSFTNGP09.phx.gbl...
> Red Gate has a tool called SQL Compare
> http://www.red-gate.com/
> --Keith
> "Martin Hart - Memory Soft, S.L." <memorysoftsl _at_ infotelecom _dot_ es>
> wrote in message news:O8IXekOQFHA.244@.TK2MSFTNGP12.phx.gbl...
>
|||Martin Hart - Memory Soft, S.L. wrote:
> Hi:
> I am looking for a tool/utility that can compare 2 tables (indexes and
> constraints etc.) and create a SQL script containing 'ALTER TABLE ...'
> statements that would update the second table so it is the same as
> the first table.
> Does anything like this exist? It's a bit of a long-shot isn't it?
>
Imceda offers Speed Change Manager. 14-day trial on web site.
David Gugick
Imceda Software
www.imceda.com
|||Keith:
Thanks, looks *very* interesting.
Regards,
MartinH.
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> escribi en el mensaje
news:%23ux6lzOQFHA.3928@.TK2MSFTNGP09.phx.gbl...
> Red Gate has a tool called SQL Compare
> http://www.red-gate.com/
> --Keith
> "Martin Hart - Memory Soft, S.L." <memorysoftsl _at_ infotelecom _dot_ es>
> wrote in message news:O8IXekOQFHA.244@.TK2MSFTNGP12.phx.gbl...
>
|||Innovartis does DB Ghost - more than a comparison tool - 30 day trial
regards,
Mark Baekdal
http://www.dbghost.com
http://www.innovartis.co.uk
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"Martin Hart - Memory Soft, S.L." wrote:

> Hi:
> I am looking for a tool/utility that can compare 2 tables (indexes and
> constraints etc.) and create a SQL script containing 'ALTER TABLE ...'
> statements that would update the second table so it is the same as the first
> table.
> Does anything like this exist? It's a bit of a long-shot isn't it?
> TIA,
> MartinH.
>
>
|||Could you tell me Where is the web site ?
Thanks a lot
"mark baekdal" <markbaekdal@.discussions.microsoft.com> glsD:F9AC3991-7F4F-4C29-BA6D-0D52E03FB1C5@.microsoft.com...[vbcol=seagreen]
> Innovartis does DB Ghost - more than a comparison tool - 30 day trial
>
> regards,
> Mark Baekdal
> http://www.dbghost.com
> http://www.innovartis.co.uk
> +44 (0)208 241 1762
> Build, Comparison and Synchronization from Source Control = Database
> change
> management for SQL Server
>
>
> "Martin Hart - Memory Soft, S.L." wrote:
|||http://www.dbghost.com
"Agnes" wrote:

> Could you tell me Where is the web site ?
> Thanks a lot
> "mark baekdal" <markbaekdal@.discussions.microsoft.com> ???g?ó?l¥ó·s?D:F9AC3991-7F4F-4C29-BA6D-0D52E03FB1C5@.microsoft.com...
>
>

Dodgy Results AS400 linked server

Hi
I have an AS400 linked server in SQL Server 2000. Using IBM's iSeries Access
ODBC Driver (filename : CWBODBC.DLL, Ver 9.00.08.00).
When I run a query in query analyser it does not return all of the records.
I am getting "Error converting data type DBTYPE_DBTIMESTAMP to datetime."
It definitely is not returning all of rows as SELECT COUNT(*) FROM ...
reveals that there are more records. Whereas SELECT * ... returns only a
subset of the data and reports the error above.
If I omit the date field I get all of the rows. i.e. SELECT ColA as
NonDateField FROM ...
Also if I select just the datefield, I get more rows i.e. SELECT ColB as
ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
all of them.
Whats going on?!!!
It almost seems as though there is some sort of buffer/bytes limit on the
data that it can return.
Do you guys who have a linked AS400 get all of your required data ?
Sorry this bit in my previous post ;
"Also if I select just the datefield, I get more rows i.e. SELECT ColB as
ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
all of them. "
is incorrect please ignore (I get the same number of rows)
|||Interfacing with an AS400 can work and be stable but you
need the right driver or provider, need to keep it current,
need to keep up on any necessary service packs for it, etc.
I used Client Access and the HIT software providers for
AS400s before. HIT providers were good and we didn't run
into many problems(if any really) with their drivers or
providers. IBMs drivers weren't as stable.
What you are hitting isn't likely to be a SQL Server issue -
more likely related to the driver or the client setup,
dependent files for the driver.
-Sue
On Wed, 2 May 2007 07:18:01 -0700, Jane
<Jane@.discussions.microsoft.com> wrote:

>Sorry this bit in my previous post ;
>"Also if I select just the datefield, I get more rows i.e. SELECT ColB as
>ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
>all of them. "
>is incorrect please ignore (I get the same number of rows)

Dodgy Results AS400 linked server

Hi
I have an AS400 linked server in SQL Server 2000. Using IBM's iSeries Access
ODBC Driver (filename : CWBODBC.DLL, Ver 9.00.08.00).
When I run a query in query analyser it does not return all of the records.
I am getting "Error converting data type DBTYPE_DBTIMESTAMP to datetime."
It definitely is not returning all of rows as SELECT COUNT(*) FROM ...
reveals that there are more records. Whereas SELECT * ... returns only a
subset of the data and reports the error above.
If I omit the date field I get all of the rows. i.e. SELECT ColA as
NonDateField FROM ...
Also if I select just the datefield, I get more rows i.e. SELECT ColB as
ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
all of them.
Whats going on'!!!
It almost seems as though there is some sort of buffer/bytes limit on the
data that it can return.
Do you guys who have a linked AS400 get all of your required data ?Sorry this bit in my previous post ;
"Also if I select just the datefield, I get more rows i.e. SELECT ColB as
ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but not
all of them. "
is incorrect please ignore (I get the same number of rows)|||Interfacing with an AS400 can work and be stable but you
need the right driver or provider, need to keep it current,
need to keep up on any necessary service packs for it, etc.
I used Client Access and the HIT software providers for
AS400s before. HIT providers were good and we didn't run
into many problems(if any really) with their drivers or
providers. IBMs drivers weren't as stable.
What you are hitting isn't likely to be a SQL Server issue -
more likely related to the driver or the client setup,
dependent files for the driver.
-Sue
On Wed, 2 May 2007 07:18:01 -0700, Jane
<Jane@.discussions.microsoft.com> wrote:

>Sorry this bit in my previous post ;
>"Also if I select just the datefield, I get more rows i.e. SELECT ColB as
>ThisIsTheDateField FROM ... I get more rows than SELECT * FROM ... but no
t
>all of them. "
>is incorrect please ignore (I get the same number of rows)