Jumat, 03 Agustus 2012

Bls: Bls: [MS_AccessPros] Re: vba to make Pass through Queries (with no DSN)

 

Thank you Steve,..
It's interesting since i can't find any right connection syntax to run DSN-Less PTQ,...
Would you give me the example like quote ? : (assumed that we don't use linked table)

q.Connect = fSQLconnectString ' my function that assembles connect string

i've tried theese (my own codes) and doesn't work :
strConnect = "{DRIVER=MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=CobaLink;User=root;Password=123456;"
qdfPassThrough.Connect = "ODBC;" & strConnect

the erorr is : "failed to connect ....."
From the beginning i'm sure there is a way to run DSN-Less PTQ.

Regards
Hendra

________________________________
Dari: Steve Conklin <StephenMConklin@hotmail.com>
Kepada: MS Access Pros List <ms_access_professionals@yahoogroups.com>
Dikirim: Sabtu, 4 Agustus 2012 11:59
Judul: RE: Bls: [MS_AccessPros] Re: vba to make Pass through Queries (with no DSN)


Ok, disclaimer, I did not see everything in this thread, though I did try to answer early on ... I am a little confused tha it seems that DSN-less and ODBC are spoken about as being in oppostion.

I use DSN-less ODBC all the time ... I disliked needing to deal with Control Panel / ODBC Data Sources so my FE's to MSSQL use a local table that srores connection info. All linked tables are refreshed on startup using the Server/DB/User/Pwd info from the local table. Startup routine creates a string that says "ODBC; some server, some database, user pwd" ; all linked tables get this as connect property. SO, I think I am DSN-less AND Odbc ...

Then when I need to use a PT, which are not a security panacea (nothing is for security), PTs sure can give better performance when used properly, I use code like this :

Public Function DoPassThru(stQdefName As String, Optional sp_name As String, _
    Optional stParams As String, Optional blnReturnsRecords As Boolean) As Boolean

Dim q As QueryDef

On Eror GoTo pt_err

Set q = CurrentDb.QueryDefs(stQdefName)

q.Connect = fSQLconnectString ' my function that assembles connect string

' OR

' q.Connect = CurrentDb.TableDefs("dbo_tbl_client").Connect ' a main table you know is linked

q.ReturnsRecords = blnReturnsRecords

q.SQL = sp_name & " " & stParams  ' Me.RelationshipID

CurrentDb.QueryDefs.Refresh

'then go Execute the query

hth

Steve

To: MS_Access_Professionals@yahoogroups.com
From: wrmosca@comcast.net
Date: Sat, 4 Aug 2012 03:22:09 +0000
Subject: Bls: [MS_AccessPros] Re: vba to make Pass through Queries (with no DSN)

Hendra

So, it is as I predicted. You need to use a DSN file. The code I gave you does not require a DSN. Hence, you are opening a DSN-less connection.
Forget pass-through queries. They are not the answer to security.

Bill

--- In MS_Access_Professionals@yahoogroups.com, Agestha Hendra <agesthahendra@...> wrote:
>
> Bill,..
>
> Yes i had tried them....and....they both didn't work,...
> the process asked a DSN to continue,... :(
> Thank you Bill,...
>
> Regards
> Hendra
>
>
> ________________________________
> Dari: Bill Mosca <wrmosca@...>
> Kepada: MS_Access_Professionals@yahoogroups.com
> Dikirim: Sabtu, 4 Agustus 2012 3:23
> Judul: Bls: [MS_AccessPros] Re: vba to make Pass through Queries (with no DSN)
>
>
> Â
> Hendra
>
> Why don't you give it a try and see if you can create a new query using the methods at those links?
>
> Let us know what happens.
>
> Bill
>
> --- In MS_Access_Professionals@yahoogroups.com, Agestha Hendra <agesthahendra@> wrote:
> >
> > Thanx a lot Bill,...
> >
> > I was trying to search about DSN_Less PTQ too..., i found some :
> >
> > http://www.dbforums.com/microsoft-access/1006185-writing-pass-through-queries-vba.html
> >
> > and
> >
> > http://stackoverflow.com/questions/10744170/how-do-i-create-a-passthrough-query-in-access-using-a-dsn-less-connection
> >
> > i have not tried it yet, how do you think about thoose links about...?
> >
> > Regards
> > Hendra
> >
> >
> >
> > ________________________________
> > Dari: Bill Mosca <wrmosca@>
> > Kepada: MS_Access_Professionals@yahoogroups.com
> > Dikirim: Sabtu, 4 Agustus 2012 0:56
> > Judul: Bls: [MS_AccessPros] Re: vba to make Pass through Queries (with no DSN)
> >
> >
> > ÂÂ
> > Hendra - Important!!!
> >
> > Be sure to set the cnn.ConnectionTimeout = 60
> >
> > Otherwise, if your code has a syntax error or you misspell either the SQL Server instance or database Access will just freeze up.
> >
> > Bill
> >
> > --- In MS_Access_Professionals@yahoogroups.com, "Bill Mosca" <wrmosca@> wrote:
> > >
> > > Hendra
> > >
> > > I used a windows authentication DSN. That's why there is no password or user ID.
> > >
> > > By the way, After spending about 30 minutes searching for a way to create a DSN-less passthrough I've come to the conclusion that it is impossible. Access has to use ODBC. That requires a DSN even if you don't see it in the query's connection string.
> > >
> > > On the other hand, you can open a recordset using ADO and that can be DSN-less.
> > >
> > > Typical code:
> > >
> > > Option Compare Database
> > > Option Explicit
> > > Private cnn As ADODB.Connection
> > > Private rs As ADODB.Recordset
> > >
> > > Private Sub Form_Open(Cancel As Integer)
> > > Dim strSQL As String
> > > Dim strMSG As String
> > >
> > > On Error GoTo err_PROC
> > >
> > > Set cnn = New ADODB.Connection
> > > cnn.ConnectionString = "Provider=sqloledb;Data Source=MySQLInstance;" _
> > > & "Initial Catalog=MyDatabase;User Id=zzz_test;Password=dirtydog1"
> > > cnn.ConnectionTimeout = 0
> > > cnn.Open
> > >
> > > strSQL = "SELECT * FROM ErrorLog"
> > >
> > > Set rs = New ADODB.Recordset
> > > rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
> > >
> > > Set Me.Recordset = rs
> > >
> > > exit_PROC:
> > > On Error Resume Next
> > > Exit Sub
> > >
> > > err_PROC:
> > > Dim strErrMsg As String
> > > Dim lngIcon As Long
> > >
> > > strErrMsg = "Error " & Err.Number & " (" & Err.Description & ") " _
> > > & "occurred in procedure Form_Open of " _
> > > & "VBA Document Form_frm_dbo_Errorlog"
> > > lngIcon = vbOKOnly + vbInformation
> > >
> > > MsgBox strErrMsg, lngIcon, "Error"
> > >
> > > Resume exit_PROC
> > >
> > >
> > > End Sub
> > >
> > > Private Sub Form_Unload(Cancel As Integer)
> > > Set rs = Nothing
> > > Set cnn = Nothing
> > >
> > > End Sub
> > >
> > > Bill
> > >
> > > --- In MS_Access_Professionals@yahoogroups.com, Agestha Hendra <agesthahendra@> wrote:
> > > >
> > > > Thank you Steve,..
> > > >
> > > > May i have your complete codes example to do that,...i'm beginner in VBA,..
> > > >
> > > > Regards
> > > > Hendra
> > > >
> > > >
> > > >
> > > > ________________________________
> > > > Dari: Steve Conklin <StephenMConklin@>
> > > > Kepada: MS Access Pros List <ms_access_professionals@yahoogroups.com>
> > > > Dikirim: Jumat, 3 Agustus 2012 23:33
> > > > Judul: RE: [MS_AccessPros] Re: vba to make Pass through Queries (with no DSN)
> > > >
> > > >
> > > > If you have a linked table to the same database, you can borrow that table's connect property (that's what I usually do).qPT.connect=currentdb.tabledefs("some odbc linked table").connect Steve
> > > > To: MS_Access_Professionals@yahoogroups.com
> > > > From: wrmosca@
> > > > Date: Fri, 3 Aug 2012 15:21:45 +0000
> > > > Subject: [MS_AccessPros] Re: vba to make Pass through Queries (with no DSN)
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > ÂÂ
> > > >
> > > >
> > > >  ÂÂ
> > > >   ÂÂ
> > > >   ÂÂ
> > > >    Hendra
> > > >
> > > >
> > > >
> > > > The easiest way I know is to create a DSN file and use the builder button in the properties box to select it as the connection string. It doesn't actually use the DSN file. It just copies the parameters.
> > > >
> > > >
> > > >
> > > > A typical connection string to a SQL Server database using windows Authentication would look like this:
> > > >
> > > >
> > > >
> > > > ODBC;DRIVER=SQL Server;SERVER=InstanceNameGoesHere;DATABASE=DBNameGoesHere;Trusted_Connection=Yes
> > > >
> > > >
> > > >
> > > > Regards,
> > > >
> > > > Bill Mosca, Founder - MS_Access_Professionals
> > > >
> > > > http://www.thatlldoit.com
> > > >
> > > > Microsoft Office Access MVP
> > > >
> > > > https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-64270730881E
> > > >
> > > > My nothing-to-do-with-Access blog
> > > >
> > > > http://wrmosca.wordpress.com
> > > >
> > > >
> > > >
> > > > --- In MS_Access_Professionals@yahoogroups.com, "agesthahendra@" <agesthahendra@> wrote:
> > > >
> > > > >
> > > >
> > > > > Hi Everyone,...
> > > >
> > > > >
> > > >
> > > > > I'm trying to write VBA to make a PTQ but with no DSN in the syntax but
> > > >
> > > > > using Connection string since connection string don't require a DSN.
> > > >
> > > > > Any example to do this would be appreciated...thank you.
> > > >
> > > > >
> > > >
> > > > > Regards
> > > >
> > > > > Hendra
> > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >  ÂÂ
> > > >  ÂÂ
> > > >
> > > >  ÂÂ
> > > >  ÂÂ
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >                  ÂÂ
> > > >
> > > > [Non-text portions of this message have been removed]
> > > >
> > > >
> > > >
> > > > ------------------------------------
> > > >
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > > [Non-text portions of this message have been removed]
> > > >
> > >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> [Non-text portions of this message have been removed]
>

<!-- .ExternalClass #ecxygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;padding:0 10px;} .ExternalClass #ecxygrp-mkp hr {border:1px solid #d8d8d8;} .ExternalClass #ecxygrp-mkp #ecxhd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;} .ExternalClass #ecxygrp-mkp #ecxads {margin-bottom:10px;} .ExternalClass #ecxygrp-mkp .ecxad {padding:0 0;} .ExternalClass #ecxygrp-mkp .ecxad p {;} .ExternalClass #ecxygrp-mkp .ecxad a {color:#0000ff;text-decoration:none;} .ExternalClass #ecxygrp-sponsor #ecxygrp-lc {font-family:Arial;} .ExternalClass #ecxygrp-sponsor #ecxygrp-lc #ecxhd {font-weight:700;font-size:78%;line-height:122%;} .ExternalClass #ecxygrp-sponsor #ecxygrp-lc .ecxad {margin-bottom:10px;padding:0 0;} .ExternalClass a {color:#1e66ae;} .ExternalClass #ecxactions {font-family:Verdana;font-size:11px;padding:10px 0;} .ExternalClass #ecxactivity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}
.ExternalClass #ecxactivity span {font-weight:700;} .ExternalClass #ecxactivity span a {color:#5085b6;text-decoration:none;} .ExternalClass #ecxactivity span span {color:#ff7900;} .ExternalClass #ecxactivity span .ecxunderline {text-decoration:underline;} .ExternalClass .ecxattach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;} .ExternalClass .ecxattach div a {text-decoration:none;} .ExternalClass .ecxattach img {border:none;padding-right:5px;} .ExternalClass .ecxattach label {display:block;margin-bottom:5px;} .ExternalClass .ecxattach label a {text-decoration:none;} .ExternalClass blockquote {;} .ExternalClass .ecxbold {font-family:Arial;font-size:13px;font-weight:700;} .ExternalClass .ecxbold a {text-decoration:none;} .ExternalClass dd.ecxlast p a {font-family:Verdana;font-weight:700;} .ExternalClass dd.ecxlast p span {margin-right:10px;font-family:Verdana;font-weight:700;} .ExternalClass dd.ecxlast p
span.ecxyshortcuts {margin-right:0;} .ExternalClass div.ecxattach-table div div a {text-decoration:none;} .ExternalClass div.ecxattach-table {width:400px;} .ExternalClass div.ecxfile-title a, .ExternalClass div.ecxfile-title a:active, .ExternalClass div.ecxfile-title a:hover, .ExternalClass div.ecxfile-title a:visited {text-decoration:none;} .ExternalClass div.ecxphoto-title a, .ExternalClass div.ecxphoto-title a:active, .ExternalClass div.ecxphoto-title a:hover, .ExternalClass div.ecxphoto-title a:visited {text-decoration:none;} .ExternalClass ecxdiv#ygrp-mlmsg #ecxygrp-msg p a span.ecxyshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;} .ExternalClass .ecxgreen {color:#628c2a;} .ExternalClass .ecxMsoNormal {;} .ExternalClass ecxo {font-size:0;} .ExternalClass #ecxphotos div {float:left;width:72px;} .ExternalClass #ecxphotos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;} .ExternalClass #ecxphotos div label
{color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;} .ExternalClass #ecxreco-category {font-size:77%;} .ExternalClass #ecxreco-desc {font-size:77%;} .ExternalClass .ecxreplbq {;} .ExternalClass #ecxygrp-mlmsg {font-size:13px;font-family:Arial, helvetica,clean, sans-serif;} .ExternalClass #ecxygrp-mlmsg table {font-size:inherit;font:100%;} .ExternalClass #ecxygrp-mlmsg select, .ExternalClass input, .ExternalClass textarea {font:99% Arial, Helvetica, clean, sans-serif;} .ExternalClass #ecxygrp-mlmsg pre, .ExternalClass code {font:115% monospace;} .ExternalClass #ecxygrp-mlmsg ecx* {line-height:1.22em;} .ExternalClass #ecxygrp-mlmsg #ecxlogo {padding-bottom:10px;} .ExternalClass #ecxygrp-mlmsg a {color:#1E66AE;} .ExternalClass #ecxygrp-msg p a {font-family:Verdana;} .ExternalClass #ecxygrp-msg ecxp#attach-count span {color:#1E66AE;font-weight:700;} .ExternalClass #ecxygrp-reco #ecxreco-head
{color:#ff7900;font-weight:700;} .ExternalClass #ecxygrp-reco {margin-bottom:20px;padding:0px;} .ExternalClass #ecxygrp-sponsor #ecxov li a {font-size:130%;text-decoration:none;} .ExternalClass #ecxygrp-sponsor #ecxov li {font-size:77%;list-style-type:square;padding:6px 0;} .ExternalClass #ecxygrp-sponsor #ecxov ul {padding:0 0 0 8px;} .ExternalClass #ecxygrp-text {font-family:Georgia;} .ExternalClass #ecxygrp-text p {;} .ExternalClass #ecxygrp-text tt {font-size:120%;} -->                        

------------------------------------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar