Re: SQL Server - Filter
- From: "Bob" <bob at colsoft dot com dot .au>
- Date: Wed, 11 Jan 2006 08:15:33 +1030
Steve,
Yes Rich missd my point actually!
> Sure, but that doesn't mean you have to turn the whole app inside out. If
> adjusting the Access query doesn't give the same benefits you're
> describing, then perhaps a stored procedure should be used in that
> specific case.
Happy to use a stored procedure but prefer to use a View that can be linked
to so that it looks like a table to Access - at least that is what I think I
want to do - still climbing that learning curve!
Bob Collinson
"Steve Jorgensen" <nospam@xxxxxxxxxxxxx> wrote in message
news:V9-dnVvJ_cdtTF7eRVn-hw@xxxxxxxxxxxxxx
> Rich P wrote:
>> Hi Bob,
>>
>> If you are connecting to sql server via ODBC and running queries agains
>> the sql server tables from access you are pretty much defeating the idea
>> of using a sql server. The idea is for the sql server to do the work.
>
> Now, your code example below looks like a very nice implementation for
> certain kinds of application, but statements like the one above get me
> really pissed off. I've have had to support the worst kinds of
> unnecessarily complex tangled messes of code that users have created
> because they read some false statement like this one on some forum, when
> their app would have been vastly easier to implement and maintain and had
> many fewer bugs if they'd just used Access queries for the most part.
>
> The truth is that in most cases, Access works very well querying data
> using Access queries against links to server tables, and many of the
> features that make Access such a convenient platform for developing
> database applications are thwarted by shemes to use only stored procedures
> to query data from the back-end.
>
> Specifically - it is NOT true that Access must read entire back-end tables
> to the client to perform Access queries. Access generally forwards query
> logic to the back-end for processing, even when joining 2 or more tables,
> so long as they are linked to the same ODBC source.
>
> Of the cases where Access cannot run efficient queries against server
> tables using an Access query, 90% of those are due to problems that can be
> fixed by adjusting the query to eliminate problems like including a VBA
> function in a GROUP BY field.
>
>> You run the queries (stored procedures) in sql server and pull down the
>> result set to Access. The catch is that you don't use ODBC. Use ADO. I
>> have seen people at my place run queries against the sql server tables
>> from Access - 45 minutes later they are still waiting for a result set.
>> Eventually, I wrote them a stored procedure for the same query in sql
>> server. 45 minutes turned into 450 miliseconds. No kidding!
>
> Sure, but that doesn't mean you have to turn the whole app inside out. If
> adjusting the Access query doesn't give the same benefits you're
> describing, then perhaps a stored procedure should be used in that
> specific case.
>
>> Here is a sample how you run a stored procedure in sql server from
>> access and pull down the result set - this example assumes you are
>> pulling data for a specified date range, so you have date parameters for
>> start date and end date -- Note: you need to make a reference in
>> Tools/Reference/Microsoft ActiveX Data Objects 2.6 Library or higher.
>> You get this from MDAC2.6. Note also, you need to have MDAC2.5 loaded
>> because MDAC2.5 was the last MDAC to include Jet4.0. Get this from MDSN
>> or google it.
>>
>> Sub GetResultSetFromSqlSvr()
>> Dim cmd As New ADODB.Command, RSado As New ADODB.Recordset
>> Dim RSdao As DAO.Recordset, j As Integer, Retval As variant
>>
>> cmd.ActiveConnection = "Provider=SQLOLEDB;" _
>> & "Data Source=yourServer;" _
>> & "Initial Catalog=yourSqlServerDB;UID=sa;PWD=;"
>> cmd.CommandTimeout = 600
>> cmd.CommandType = adCmdStoredProc
>> cmd.CommandText = "stp_YourStoredProc"
>> cmd.Parameters("@bDate").Value = sDate
>> cmd.Parameters("@eDate").Value = eDate
>> Set RSado = cmd.Execute
>> Set RSdao = CurrentDb.OpenRecordset("yourAccessTable")
>> DoEvents
>> Do While Not RSado.EOF
>> RSdao.AddNew
>> For i = 0 To RSado.Fields.Count - 1
>> RSdao(i) = RSado(i)
>> Next
>> RSdao.Update
>> RSado.MoveNext
>> j = j + 1
>> RetVal = SysCmd(acSysCmdSetStatus, j)
>> Loop
>> RSado.Close
>> End Sub
>>
>>
>> Rich
>>
>> *** Sent via Developersdex http://www.developersdex.com ***
.
- Follow-Ups:
- Re: SQL Server - Filter
- From: Steve Jorgensen
- Re: SQL Server - Filter
- References:
- SQL Server - Filter
- From: Bob
- Re: SQL Server - Filter
- From: Rich P
- Re: SQL Server - Filter
- From: Steve Jorgensen
- SQL Server - Filter
- Prev by Date: Re: A97 - how to transfer a file from https?
- Next by Date: Re: A2K3- quick SQL help needed
- Previous by thread: Re: SQL Server - Filter
- Next by thread: Re: SQL Server - Filter
- Index(es):
Relevant Pages
|