Showing posts with label fairly. Show all posts
Showing posts with label fairly. Show all posts

Friday, March 23, 2012

Of Multiple Parameters, SqlDataSource and Text boxes

Hi,
Hope if someone can help me here. Keep in mind I an fairly new to .NET and SQL and am learning to break my MS Access habit :)


I have a web form that is using a SqlDataSource and a FormView control. In addition to this I have 2 text boxes. What I am trying to do is display results in the FormView based on what a user types into one of the Text Boxes (one or the other…Not both)

The SELECT statement in the SqlDataSource looks like this in concept.

SELECT Field1, Field2, Field3, Field4
FROM dbo.MYTABLE
WHERE (Field1 = @.Field1) AND (Field2 IS NULL)
OR (Field2 = @.Field2) AND (Field1 IS NULL)

I have the two text boxes pointing at the parameters (@.Field1 and @.Field2) so in theory I would expect that when a user populates one of the text boxes and clicks a button to databind the FormView it would display a record matching that criteria…. But it's not all I get is a blank/missing FormView.

I tried different variations on the SQL statement and tried using = '' instead of IS NULL but still the same results.
However, if I populate one text box with a value that I know is not in my table and populate the other with a value of which I know exists in my table is…It works.
What am I missing?


SELECT Field1, Field2, Field3, Field4
FROM dbo.MYTABLE
WHERE (Field1 = @.Field1) AND (Field2 IS NULL)
OR (Field2 = @.Field2) AND (Field1 IS NULL)

Should be:

SELECT Field1, Field2, Field3, Field4
FROM dbo.MYTABLE
WHERE (Field1 = @.Field1) AND (@.Field2 IS NULL)
OR (Field2 = @.Field2) AND (@.Field1 IS NULL)

However, I suspect that there are other issues you are having, as your original statement would have only worked if you actually had a NULL in one of your search fields. Please copy and paste the SqlDataSource control from the .ASPX page, as I'm guessing that it's not really a logical problem, more like an oops, I knew that problem.

|||

Opps yeah...That was a typo on my part. Well the field in the text box is blank and I have "ConvertEmptyString ToNull" in the parameters advanced properties set to true. But, your right it is behaving as though the query not seeing null.

Is there syntax to set the default value of the parameter to null in the Configure Data Source/Query Builder pop up ? (Using VS 2005)

|||

Here is the code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:QualityConnectionString %>"

SelectCommand="SELECT WWID, WONumber, WorkWeek, ID FROM dbo.WorkOrderInfo WHERE (ID = @.ID) AND (@.WONumber = '') OR (@.ID = '') AND (WONumber = @.WONumber)" EnableCaching="True">

<FilterParameters>

<asp:ControlParameter ControlID="TextBox1" Name="ID" PropertyName="Text" />

</FilterParameters>

<SelectParameters>

<asp:ControlParameter ControlID="TextBox1" Name="ID" PropertyName="Text" />

<asp:ControlParameter ControlID="TextBox2" Name="WONumber" PropertyName="Text" />

</SelectParameters>

</asp:SqlDataSource>

|||

Remove the filter parameters section, it isn't needed, and would cause some queries to fail when they shouldn't.

Also, you either need to change ConvertEmptyStringsToNull (Real property name should be close) to false, OR change the ='' parts of your query to IS NULL, since the empty string parameters are being converted to NULL. That should take care of it for you.

|||

OK have this now and still not working. Could it have something to do with VB passing NULL as Nothing?

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:QualityConnectionString %>"

SelectCommand="SELECT WONumber, ID, WWID, WorkWeek FROM dbo.WorkOrderInfo WHERE (ID = @.ID) AND (WONumber IS NULL) OR (ID IS NULL) AND (WONumber = @.WONumber)">

<SelectParameters>

<asp:ControlParameter ControlID="TextBox1" Name="ID"

PropertyName="Text" Type="Int32" DefaultValue="" />

<asp:ControlParameter ControlID="TextBox2" Name="WONumber" PropertyName="Text"

Type="Int32" />

</SelectParameters>

</asp:SqlDataSource>

|||

took out the default values...same result

OK have this now and still not working. Could it have something to do with VB passing NULL as Nothing?

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:QualityConnectionString %>"

SelectCommand="SELECT WONumber, ID, WWID, WorkWeek FROM dbo.WorkOrderInfo WHERE (ID = @.ID) AND (WONumber IS NULL) OR (ID IS NULL) AND (WONumber = @.WONumber)">

<SelectParameters>

<asp:ControlParameter ControlID="TextBox1" Name="ID"

PropertyName="Text" Type="Int32" />

<asp:ControlParameter ControlID="TextBox2" Name="WONumber" PropertyName="Text"

Type="Int32" />

</SelectParameters>

</asp:SqlDataSource>

|||

I'm pretty sure you have it right. Try making a new page, then copy/paste the SqlDataSource on it. Drag 2 NEW textboxes on the new page, and drag a NEW gridview on the page. Configure the grid to display data from the sqldatasource, and run the page and see if it works.

|||Tried from scratch same result. The empty text boxes must not be passing a Null. I found a work around by setting the default paramater values to a negative integer and leaving out the @.parameter IS NULL ...But this is driving me insane!|||

try this instead:

SELECT WONumber, ID, WWID, WorkWeek FROM dbo.WorkOrderInfo WHERE ((ID = @.ID) OR (@.ID IS NULL)) AND ((WONumber = @.WONumber) OR (@.WONumber IS NULL))

The parameters should have no defaults, and convertemtystringtonull should be true.

|||

That didn't work either. Setting ConvertEmptyString ToNull toFalse and the below SQL statement works though. I thought I tried that before but must have missed a parameter property setting.

SELECT WONumber, ID, WWID, WorkWeek FROM dbo.WorkOrderInfo WHERE (ID = @.ID) OR (WONumber = @.WONumber)

This is odd because I have another page with a reportviewer that uses a table adaptor etc. and several text boxes for passing parameters to a stored procedure to generate data for the report. Any one of them can be null and it works great. Not sure what is going on here though.

|||I also changed to parameter type to "Empty" (default) not int32...|||

Agh!! I was wrong it actualy does not work the way I wanted. Seems the empty string (blank text box) for the WONumber parameter thinks it is a zero too. So for any WONumber that is 0 and the text box being empty, it will retireve that record.

Theonlyway I can get to work is a stored procedure.

CREATE PROCEDURE dbo.SelectWO(@.ID int,
@.WONumber int )
AS
If @.ID = ''
SET @.ID = Null
If @.WONumber = ''
SET @.WONumber = Null
SELECT ID, WWID, WONumber,FROM dbo.WorkOrderInfo
WHERE (ID = @.ID AND @.WONumber IS NULL) OR (WONumber = @.WONumber AND @.ID IS NULL)

OR( @.ID IS NULL AND @.WONumber IS NULL)

ORDER BY ID
GO

Had to leave ConvertEmptyStringtoNull to false and convert in my SP. setting it to True in VS breaks the SP.

Anyone ...try to build a web form with 2 search parameters getting thier values from to text boxes see if you can get it working cause I could not.


|||

/sigh

CREATE PROCEDURE dbo.SelectWO(@.ID int,
@.WONumber int )
AS
SELECT ID, WWID, WONumber,FROM dbo.WorkOrderInfo
WHERE (ID = @.ID AND @.WONumber IS NULL) OR (WONumber = @.WONumber AND @.ID IS NULL)OR( @.ID IS NULL AND @.WONumber IS NULL)
ORDER BY ID
GO

Is the SP you want. Change the ConvertEmptyStringToNull's on both parameters to true, and explicitly set the parameter types to "int"/"integer". Also make sure you set the sqldatasouce property "CancelOnNullParameter" to false.

It'll work.

The problem is that yes, if you leave ConvertEmptyStringToNull false, the paramters will be converted to 0. Your checks IF @.ID='' will never be true, but @.ID is an int, and int's can never be an empty string. They can only be an integer or NULL.

Tuesday, March 20, 2012

Odd error with Reporting Services and Oracle

I've got a fairly simple report that hits oracle with two parameters set as strings.

When I run the query in the designer, I get

Error Source: System.Data.OracleClient
Error Message: ORA-01858: a non-numeric character was found where a numeric was expected

However, when I run the report in preview everything just works. Same inputs on the parameters.

Any ideas?

What types are your parameters and what is the SQL you are using in your DataSet? I've seen this kind of error passing a parameter that is declared as a string in the report to an oracle parameter that is compared against a Date type in Oracle.

Mike

|||Sorery I meant to post a followup to this. The solution is that SQL RS 2k5 takes a string that happens to be a date and makes it a date without telling.

When it goes into oracle as this "Date" it will go in in the default SQL date format. So you need to match the format mask in the oracle TO_Date function call to the 3 letter month sql format.

Interesting, RS 2K did not do this.

Monday, March 12, 2012

ODBC--Call Failed - Collation Conflict

Hi Everyone,

I am fairly new to MS-SQL so excuse my ignorance if I have any.

I am trying to add and link a new table to an existing database. I can add the database and colums and add some data into it, and even run a query on it. However, if I try to run a query using the new table and and existing table (linked) I get the following error:

ODBC--call failed.
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot resolve collation conflict for equal to operation. (#446)

Any ideas?

my Server and SQL specs: SBS2003 & MSSQL ver 8.0what's the query you are executing?|||A Simple or Single Join Query|||post it here.|||Here is the query :

SELECT ChangeCustidLog.NewCustid, Customer.CustId, Customer.CustName
FROM ChangeCustidLog INNER JOIN Customer ON ChangeCustidLog.NewCustid = Customer.CustId;|||try this:

SELECT ChangeCustidLog.NewCustid, Customer.CustId, Customer.CustName
FROM ChangeCustidLog
INNER JOIN Customer ON
ChangeCustidLog.NewCustid COLLATE Latin1_General_CI_AS =
Customer.CustId COLLATE Latin1_General_CI_AS;|||thank you,

the query works fine with the 'collate' phrase, when run in SQL server. I am having trouble when the query runs in Access (and thats where the linked tables are)..

is there a way to fix this 'collate' problem??

ODBC-Call Failed - Access

We have this fairly simple Access database with a link table to a view in an SQL Server. The Select Query in Access is a simple select from this view with a view criteria set. Nothing fancy. What is driving is moderately crazy is that this Select Query in Access seems to work fine for months and than all of a sudden (same query performed around the same time with about the same workload on the SQL-Server) it responses with the helpful "ODBC-Call Failed" message. Closing the Access database, taking a coffee, coming back againg and try the exact same Select Query normally works, no "ODBC-Call Failed" message.

    It not happens always, mosty we're fine.

    When it happens it happens for all subsequent queries tried. We have to close and reopen the Access database and pray to the good Lord that it works.

We would be very interested in someone with a solution to this problem.

What ODBC driver and version are you using and to what version of SQL Server are you connecting?

You might want to try out a different ODBC driver in your DSN to see if that resolves the problem.

Vaughn

|||We are having the same problem using Access 2003 and SQL Server 8.0. I'm using the standard SQL Server driver in the DSN. Any suggestions?|||

Reading a bit it sounds like the "ODBC-Call Failed" message is coming from Access. I found this KB article that describes a similar problem for DB2 and suggests updating Jet as the solution.

http://support.microsoft.com/kb/227413/

I see you're using Access 2003 so this isn't likely the cause. Have you tried ODBC tracing through the ODBC Data Source Administrator control panel? Correlating that log to when the failure occurs might provide more clues as to the cause.

Vaughn

|||The problem is that I don't know what is the cause of the error. Is it a timeout on the client (MSAccess) side? Is it a deadlock situation? Is it table lock that couldn not be caried out? etc. Neither SQL Server nor MSAccess seem to bother to explain what's wrong. If if happend all the time I would look at replacing drivers but now I feel this should be somewhere else. Btw ODBC tracing gives me a bunch data wich not really eplains what 's going on.|||

So, this might have been a timeout afterall. In design view I changed the properties of the view from Snapshot to "Dynaset (Inconsistent Updates)" (although MS fails to describe in the online help what that exactly means). I would go with Snapshot as there is no need to update the data, but due to the fairly large amount of records, MS recommends using Dynaset. Furthermore the Timeout of the view was changed to 900 seconds (15min), if our SQL Server is doing some real work this is probably not enough. It would be helpfull that instead of ODBC-Call failed, MS-Access would report something like "Timeout expired", but there probably is a deeper reason why this is not possible.

Leaving the question: Dynaset, Dynaset (Inconsistent Updates), Snapshot? As an experienced P/SQL and T/SQL I have no clue what MSAccess is talking about here. The documentation is pretty dodgy also. I fact I only need to read the data (it's for reporting).

|||

I found some information that may shed some light on the differences at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acproRecordsetType_HV05187937.asp

Basically, a Dynaset allows you to make changes in controls bound to a single table or tables with a one-to-one relationship. You can also edit the fields from a table on the "many" side of a one-to-many relationship.

A Dynaset (Inconsistent) allows you to update all data fields.

ODBC-Call Failed - Access

We have this fairly simple Access database with a link table to a view in an SQL Server. The Select Query in Access is a simple select from this view with a view criteria set. Nothing fancy. What is driving is moderately crazy is that this Select Query in Access seems to work fine for months and than all of a sudden (same query performed around the same time with about the same workload on the SQL-Server) it responses with the helpful "ODBC-Call Failed" message. Closing the Access database, taking a coffee, coming back againg and try the exact same Select Query normally works, no "ODBC-Call Failed" message.

    It not happens always, mosty we're fine.

    When it happens it happens for all subsequent queries tried. We have to close and reopen the Access database and pray to the good Lord that it works.

We would be very interested in someone with a solution to this problem.

What ODBC driver and version are you using and to what version of SQL Server are you connecting?

You might want to try out a different ODBC driver in your DSN to see if that resolves the problem.

Vaughn

|||We are having the same problem using Access 2003 and SQL Server 8.0. I'm using the standard SQL Server driver in the DSN. Any suggestions?|||

Reading a bit it sounds like the "ODBC-Call Failed" message is coming from Access. I found this KB article that describes a similar problem for DB2 and suggests updating Jet as the solution.

http://support.microsoft.com/kb/227413/

I see you're using Access 2003 so this isn't likely the cause. Have you tried ODBC tracing through the ODBC Data Source Administrator control panel? Correlating that log to when the failure occurs might provide more clues as to the cause.

Vaughn

|||The problem is that I don't know what is the cause of the error. Is it a timeout on the client (MSAccess) side? Is it a deadlock situation? Is it table lock that couldn not be caried out? etc. Neither SQL Server nor MSAccess seem to bother to explain what's wrong. If if happend all the time I would look at replacing drivers but now I feel this should be somewhere else. Btw ODBC tracing gives me a bunch data wich not really eplains what 's going on.|||

So, this might have been a timeout afterall. In design view I changed the properties of the view from Snapshot to "Dynaset (Inconsistent Updates)" (although MS fails to describe in the online help what that exactly means). I would go with Snapshot as there is no need to update the data, but due to the fairly large amount of records, MS recommends using Dynaset. Furthermore the Timeout of the view was changed to 900 seconds (15min), if our SQL Server is doing some real work this is probably not enough. It would be helpfull that instead of ODBC-Call failed, MS-Access would report something like "Timeout expired", but there probably is a deeper reason why this is not possible.

Leaving the question: Dynaset, Dynaset (Inconsistent Updates), Snapshot? As an experienced P/SQL and T/SQL I have no clue what MSAccess is talking about here. The documentation is pretty dodgy also. I fact I only need to read the data (it's for reporting).

|||

I found some information that may shed some light on the differences at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acproRecordsetType_HV05187937.asp

Basically, a Dynaset allows you to make changes in controls bound to a single table or tables with a one-to-one relationship. You can also edit the fields from a table on the "many" side of a one-to-many relationship.

A Dynaset (Inconsistent) allows you to update all data fields.

ODBC-Call Failed - Access

We have this fairly simple Access database with a link table to a view in an SQL Server. The Select Query in Access is a simple select from this view with a view criteria set. Nothing fancy. What is driving is moderately crazy is that this Select Query in Access seems to work fine for months and than all of a sudden (same query performed around the same time with about the same workload on the SQL-Server) it responses with the helpful "ODBC-Call Failed" message. Closing the Access database, taking a coffee, coming back againg and try the exact same Select Query normally works, no "ODBC-Call Failed" message.

    It not happens always, mosty we're fine. When it happens it happens for all subsequent queries tried. We have to close and reopen the Access database and pray to the good Lord that it works.

We would be very interested in someone with a solution to this problem.

What ODBC driver and version are you using and to what version of SQL Server are you connecting?

You might want to try out a different ODBC driver in your DSN to see if that resolves the problem.

Vaughn

|||We are having the same problem using Access 2003 and SQL Server 8.0. I'm using the standard SQL Server driver in the DSN. Any suggestions?|||

Reading a bit it sounds like the "ODBC-Call Failed" message is coming from Access. I found this KB article that describes a similar problem for DB2 and suggests updating Jet as the solution.

http://support.microsoft.com/kb/227413/

I see you're using Access 2003 so this isn't likely the cause. Have you tried ODBC tracing through the ODBC Data Source Administrator control panel? Correlating that log to when the failure occurs might provide more clues as to the cause.

Vaughn

|||The problem is that I don't know what is the cause of the error. Is it a timeout on the client (MSAccess) side? Is it a deadlock situation? Is it table lock that couldn not be caried out? etc. Neither SQL Server nor MSAccess seem to bother to explain what's wrong. If if happend all the time I would look at replacing drivers but now I feel this should be somewhere else. Btw ODBC tracing gives me a bunch data wich not really eplains what 's going on.|||

So, this might have been a timeout afterall. In design view I changed the properties of the view from Snapshot to "Dynaset (Inconsistent Updates)" (although MS fails to describe in the online help what that exactly means). I would go with Snapshot as there is no need to update the data, but due to the fairly large amount of records, MS recommends using Dynaset. Furthermore the Timeout of the view was changed to 900 seconds (15min), if our SQL Server is doing some real work this is probably not enough. It would be helpfull that instead of ODBC-Call failed, MS-Access would report something like "Timeout expired", but there probably is a deeper reason why this is not possible.

Leaving the question: Dynaset, Dynaset (Inconsistent Updates), Snapshot? As an experienced P/SQL and T/SQL I have no clue what MSAccess is talking about here. The documentation is pretty dodgy also. I fact I only need to read the data (it's for reporting).

|||

I found some information that may shed some light on the differences at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acproRecordsetType_HV05187937.asp

Basically, a Dynaset allows you to make changes in controls bound to a single table or tables with a one-to-one relationship. You can also edit the fields from a table on the "many" side of a one-to-many relationship.

A Dynaset (Inconsistent) allows you to update all data fields.

Saturday, February 25, 2012

ODBC Native State S1T00: timeout expired

Hello :
I am very new to ODBC connectivity, but i know sql fairly
well:

What can generate a Native State Error: Native State
S1T00: timeout expired on a SQL 2000 database; NT4 OS
Server??

I am running sql database dependent applications on this
server: 3 to be exact.

e.g. I have an application which transports data that was
entered to the SQL database located on this Server via a
LAN user. This application then dynamically takes this
data and transports it to another device located on the
same sub-net as the Server for data recognition and other
functionalities. This is performed in milliseconds hence
it may be utilizing the (winmm.dll) file to accomplish
this. But the error message:

"Warning State: S1T00,Native:0, Origin: [Microsoft][ODBC
SQL Server Driver] timeout expired"

causes this process to fail along with other ODBC and SQL
dependent applictions. also my maintenance plans failed as aresult of this message..

Can someone please help/ inform me what can cause this and
how to prevent this??

Can a modem dial-in access cause this?? though it was
running fine with modem access in the past, and no change
in its configs.??

Thank you in advance

AdiggaMay check this KBA (http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q175/2/64.asp&NoWebContent=1) .