Re: ADO Connect to SQL

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Scott (sbailey_at_mileslumber.com)
Date: 05/26/04


Date: Wed, 26 May 2004 18:41:31 -0500

Connection works My only remaining problem is my SPROC that I want to pass a
single date variable like 5/24/2004 and
return records from 5/24/2004 5:30 AM to 5/25/2004 5:29.59 AM.

FIGURE 1 runs find with datetime hardcoded in the WHERE clause. I need help
building my where clause in FIGURE 2 so the SPROC concatenates the 5:30 AM
and 5:29:59 AM to the variable dtStartDate and filters like FIGURE 1. Any
ideas?

FIGURE 1

          CREATE PROCEDURE GetDowntime
          (
          @dtStartDate datetime
          )
          AS
          BEGIN
             SET NOCOUNT ON

          SELECT ShiftID AS Shift, downtime AS Downtime
          FROM mytable
          WHERE (myDateTimefield >= CONVERT(DATETIME, '2004-05-24
05:30:00', 102)) AND
                      (myDateTimefield <= CONVERT(DATETIME, '2004-05-25
05:29:59', 102))
          END
          GO

FIGURE 2

          WHERE CONVERT (varchar(12), myDateTimefield, 101) >= @dtStartDate

"dan artuso" <dan.artuso@NOSPAMnrc.ca> wrote in message
news:uoXOL%232QEHA.2716@tk2msftngp13.phx.gbl...
> Hi,
> Here are some examples of connection strings and code to open recordsets
>
> Dim cnn as ADODB.Connection
> Dim tvwRsJobs As ADODB.Recordset
> Dim strSql As string
>
> Set cnn = New ADODB.Connection
>
> 'this is if you're authenticating with Windows Authentication
> 'cnn.Open "Provider=sqloledb;" & _
> "Data Source=192.168.100.54;" & _
> "Initial Catalog=DatabaseName;" & _
> "Integrated Security=SSPI;Network Library=dbmssocn"
>
> 'fo'this is for SQL server athentication
> cnn.Open "Provider=sqloledb;" & _
> "Data Source=192.168.100.54;" & _
> "Initial Catalog=DatabaseName;" & _
> "User Id=artusohome;" & _
> "Password=whatever;Network Library=dbmssocn"
>
> 'get the dates of the jobs
> strSql = "Select Distinct DateCreated From Jobs" & strWhere & "
Order By DateCreated"
> tvwRsJobs.Open strSql, cnn, adOpenForwardOnly, adLockOptimistic
>
> --
> HTH
> Dan Artuso, MVP
>
>
> "Scott" <sbailey@mileslumber.com> wrote in message
news:OpsuHE2QEHA.2132@TK2MSFTNGP11.phx.gbl...
> > I have a standard (non access\sqp project) frontend-backend app. Below
is
> > sample code of how I get a recordset from backend.
> >
> > I'd like to know if there is a way with ADO to open a recordset on a SQL
> > Server that isn't linked to my access app, but merely on the network.
I'd
> > prefer to do it without linking to the sql table and just make the
> > connection at runtime via vba code. Can anyone provide sample code?
> >
> > Dim rs As ADODB.Recordset
> > Set rs = New ADODB.Recordset
> >
> > rs.ActiveConnection = CurrentProject.Connection
> > rs.CursorType = adOpenForwardOnly
> > rs.LockType = adLockReadOnly
> >
> > rs.Open "SELECT ShiftName from mytable"
> >
> >
>
>



Relevant Pages

  • Re: Concurrent database access in SQL 2005 Mobile
    ... Please stick to having an "dummy" connection in Open State. ... SQL CE/Mobile has a background thread that flushes the changes ... they run for long hours and we have not seen memory leaks so far. ... then opens his work forms and it's in ...
    (microsoft.public.sqlserver.ce)
  • Re: Concurrent database access in SQL 2005 Mobile
    ... Please stick to having an "dummy" connection in Open State. ... So it is a kind of asynchronous commit which happens every 10 ... I am not sure of this claim as we have many applications built on SQL CE ... then opens his work forms and it's in ...
    (microsoft.public.sqlserver.ce)
  • Access 2003 adp/proxy security - A substitute for SYSTEM_USER()
    ... We need a way for SQL to know the nt username that initiated the proxy ... Many stored procedures and views use a UDF that also depends on ... SyUserLogin and use HostIDand HostName() to find the right row. ... We've played with the Connection dialog settings, ...
    (microsoft.public.access.security)
  • RE: Logging in in background
    ... wold take all kinds of modifictions as I'd need to be checking that each SQL ... my database and all have connection strings associated with them. ... I suspect that there is also an issue on the SQL Server side as I keep ...
    (microsoft.public.access.modulesdaovba)
  • Access 2003 adp/proxy security - A substitute for SYSTEM_USER()
    ... We need a way for SQL to know the nt username that initiated the proxy ... Many stored procedures and views use a UDF that also depends on ... SyUserLogin and use HostIDand HostName() to find the right row. ... We've played with the Connection dialog settings, ...
    (microsoft.public.sqlserver.connect)