Showing posts with label elements. Show all posts
Showing posts with label elements. Show all posts

Tuesday, March 27, 2012

Binding WebService as Datasource

I've painstakingly managed to get a XmlDocument from a webservice and run this to retrieve data.

However, i cannot bind any of the returned elements to anything. Any help appreciated.


Are you using the XML data processing extension? What is the Query that you are using? More specifically, what is the Element Path for the query?

For more information, take a look at the following article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/RepServXMLDS.asp

Ian

Tuesday, March 20, 2012

Big Problems

I've come across an issue which i believe is related to Windows 2003 populating database elements, notably date/time types, and having those fields read on another platform (eg. winXP, win98) and, although everything would seem to match, comparissons fail.

For example, if i populate a datetime field with the value 22:22 (eg. 10:22 pm) from a Windows 2003 pc, then read the value of the field on another pc (eg. WinXP), and perform a comparisson in code (vb6sp5), the values are not equal.

I have observed this against Access database using DAO 2.5, 3.51 and 3.6 on both sides. Also observed against SQL Server 2000.

All i can figure is that windows 2003 is causing the problem, but i don't know how to resolve it.

I understand this is not a forum for operating system questions, but my intent would be to generate a routine which would correctly populate the database elements on the win2003 side, for proper execution on the other pcs in use.

Any help would be greatly appreciated.Do you perform your comparison in code or visually? I had to use my 2003 with client tools against 2K SQL Server and had no prob. If you're doing visual comparison then you need to also account for regional settings.|||visually everything looks the same
in code, i've compared stored results vs expected results. here's a sample of what i found:

If i stored, from the Win2003 pc, the value 0:01 (12:01am, no date) in either an access or sql server field, then attempted from a winxp pro machine to compare the stored number to winxp's interpretation of 12:01 am, the values would look to be the same, but vb would not claim them to be equal. if i check the difference between the two, surprisingly, the difference is 1.0842021724855E-19, and that's enough to cause this symptom. the difference fluctuates, with 12:23 am working and being equal when the above steps are followed. the pattern of equal/not equal is very strange indeed.

i have verified regional settings on both pcs. no problems.

this all works fine with all pc's being win2003. it seems that 2003 is treating something different, so comparisons to a value stored from the win2003, then compared on another os, it all fails.|||This is not a SQL issue. It's a VB issue. I dont get any problems like this in VB.NET. It's been so long for VB6 and I dont really feel like installing it so I wont be able to do any VB6 testing. Have you tried using VB.NET instead? I'm sure you'll be cursing at VB6 in no time once you switch to .NET. :D

Also what version of Access? 97, 2k?|||hahahaha

oh yeah, i've used vb.net and it's a much better development platform for sure. i will test this scenario in vb.net and see what the results are.

unfortunetly, i am supporting legacy applications and bumping up to vb.net does not give me the immediate solution i require.

has nobody else observed this behaviour?

access 97 and 2000
sql server 2000 (msde and enterprise) v8.00.760

Sunday, February 19, 2012

Best way to retrieve rows matching an array of Ids

My database table has approx 400,000 rows, with an integer Id as primary key
.
I have an array of ids, with N elements where N is typically between 500 and
5,000.
I want to retrieve into a collection all rows whose id matches a value in
this array.
What is the 'best' way to do this and/or what are the tradeoffs to consider?
I can imagine a number of solutions as follows:
1. A parametered query which takes a single Id parameter and returns 1 row.
Implies N round trips to the server to retrieve N rows.
2. A parametered query with an IN clause which takes n parameters "... WHERE
ID IN (@.p1, @.p2, ... , @.pn)". Implies N/n round trips to the server where
each round trip retrieves up to n rows. What is the maximum / optimal valu
e
for n in this case?
3. Build the SQL string dynamically, with an IN clause generated by
concatenating up to n Id values. Implies N/n round trips to the server wher
e
each round trip retrieves up to n rows. What is the maximum / optimal valu
e
for n in this case?
4. Create a temporary table with a single integer ID column and insert the N
Ids from my array (how?). Join the original table with this temporary table
to retrieve all matching Ids.
...
Any suggestions?You can try the solution offered in http://www.aspfaq.com/2248 ... also
check out the link there to Erland's article on array handling.
"Joe" <Joe@.discussions.microsoft.com> wrote in message
news:656DF445-E0EC-495C-B62E-0A535EBC2366@.microsoft.com...
> My database table has approx 400,000 rows, with an integer Id as primary
> key.
> I have an array of ids, with N elements where N is typically between 500
> and
> 5,000.
> I want to retrieve into a collection all rows whose id matches a value in
> this array.
> What is the 'best' way to do this and/or what are the tradeoffs to
> consider?
> I can imagine a number of solutions as follows:
> 1. A parametered query which takes a single Id parameter and returns 1
> row.
> Implies N round trips to the server to retrieve N rows.
> 2. A parametered query with an IN clause which takes n parameters "...
> WHERE
> ID IN (@.p1, @.p2, ... , @.pn)". Implies N/n round trips to the server where
> each round trip retrieves up to n rows. What is the maximum / optimal
> value
> for n in this case?
> 3. Build the SQL string dynamically, with an IN clause generated by
> concatenating up to n Id values. Implies N/n round trips to the server
> where
> each round trip retrieves up to n rows. What is the maximum / optimal
> value
> for n in this case?
> 4. Create a temporary table with a single integer ID column and insert the
> N
> Ids from my array (how?). Join the original table with this temporary
> table
> to retrieve all matching Ids.
> ...
> Any suggestions?|||Very useful resources, thanks, it's a lot clearer. In my case, the number
of values is potentially greater than will fit into an 8K string. So I thin
k
the approach will be:
1. Create the temp table
2. Concatenate as many Ids as possible into a string which does not exceed
8K and call an SP which extracts integers from the string and inserts into
the temp table.
3. Repeat step 2 until all ids in my array are processed.
4. Execute a query with a join to the temp table
5. Drop the temp table.
This will be done from a .NET application. I am concerned about the
lifetime of the temporary table? If I get a SqlException while running the
above, my code will typically close its SqlConnection object - which won't
actually close the underlying connection, just return it to the connection
pool. Presumably this means the temp table could be left lying around for
the next unsuspecting user of that connection, right?
I guess the workaround would be to check for the existence of the temp table
before step 1 above and drop it if it already exists.
"Aaron Bertrand [SQL Server MVP]" wrote:

> You can try the solution offered in http://www.aspfaq.com/2248 ... also
> check out the link there to Erland's article on array handling.
>
> "Joe" <Joe@.discussions.microsoft.com> wrote in message
> news:656DF445-E0EC-495C-B62E-0A535EBC2366@.microsoft.com...
>
>|||Arrays? Collections? Those are not SQL structures. We only have
tables. And we avoid procedural code, cursors, dynamic SQL and string
casting as much as possible -- which is about 99.99% of the time.
Load your list of ids into a one column table and use "WHERE foobar_id
IN (SELECT search_id FROM WorkingList)" in the body of the procedure.
Avoid kludges.|||I think we already established that a good approach is to load the ids into
a
(temporary) table. The question was, what is the 'best' way to load these
ids into the temporary table.
From the resources linked by Aaron Bertrand, it seems that a good approach
is to pass the array of values as a string - this means that all the values
can be passed in a single call.
Do you agree or what alternative would you recommend and why?
"--CELKO--" wrote:

> Arrays? Collections? Those are not SQL structures. We only have
> tables. And we avoid procedural code, cursors, dynamic SQL and string
> casting as much as possible -- which is about 99.99% of the time.
> Load your list of ids into a one column table and use "WHERE foobar_id
> IN (SELECT search_id FROM WorkingList)" in the body of the procedure.
> Avoid kludges.
>