PC Review


Reply
Thread Tools Rate Thread

SQL Scalar Valued function in VBA for a Access Project (ADP)

 
 
=?Utf-8?B?cm9nZ2U=?=
Guest
Posts: n/a
 
      1st Aug 2007
How do i use a SQL Server Scalar-valued function in MS Access ADP?

I have a function "fGrantAccess" in the SQL Server Database and i would like
to use it in an Access Project. The function returns a GUID from a table
depending on two parameters: user id and password.

I thought the function would operate in a similar fashion to a view or
table-valued function; however, i was mistaken.

This line's error is "Invalid Object Name"..

rdsStr = "SELECT fGrantAccess FROM dbo.fGrantAccess WHERE (" & _
"(uiLoginId='" & uName.Value & "') AND " & _
"(uiLoginPw='" & uPass.Value & "'));"

rdsADO.Open rdsStr, Application.CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly

ps. i have also tried setting the sql string to

rdsStr = "SELECT fGrantAccess FROM {fn {fGrantAccess('" & uName.Value &
"','" & uPass.Value & "')}};"

Thank you for your help...
 
Reply With Quote
 
 
 
 
RoyVidar
Guest
Posts: n/a
 
      1st Aug 2007
"rogge" <(E-Mail Removed)> wrote in message
<72EACE30-140F-40D1-8B2A-(E-Mail Removed)>:
> How do i use a SQL Server Scalar-valued function in MS Access ADP?
>
> I have a function "fGrantAccess" in the SQL Server Database and i
> would like to use it in an Access Project. The function returns a
> GUID from a table depending on two parameters: user id and password.
>
> I thought the function would operate in a similar fashion to a view
> or table-valued function; however, i was mistaken.
>
> This line's error is "Invalid Object Name"..
>
> rdsStr = "SELECT fGrantAccess FROM dbo.fGrantAccess WHERE (" & _
> "(uiLoginId='" & uName.Value & "') AND " & _
> "(uiLoginPw='" & uPass.Value & "'));"
>
> rdsADO.Open rdsStr, Application.CurrentProject.Connection,
> adOpenForwardOnly, adLockReadOnly
>
> ps. i have also tried setting the sql string to
>
> rdsStr = "SELECT fGrantAccess FROM {fn {fGrantAccess('" & uName.Value
> & "','" & uPass.Value & "')}};"
>
> Thank you for your help...


Assuming username is the first parameter, and password the second, try
something like this:

rdsStr = "SELECT dbo.fGrantAccess('" & uName.Value & "', " & _
uPass.Value & "')"

--
Roy-Vidar


 
Reply With Quote
 
Baz
Guest
Posts: n/a
 
      1st Aug 2007
Try this:

rdsStr = "SELECT dbo.fGrantAccess('" & uName & "','" & uPass & "')"

"rogge" <(E-Mail Removed)> wrote in message
news:72EACE30-140F-40D1-8B2A-(E-Mail Removed)...
> How do i use a SQL Server Scalar-valued function in MS Access ADP?
>
> I have a function "fGrantAccess" in the SQL Server Database and i would

like
> to use it in an Access Project. The function returns a GUID from a table
> depending on two parameters: user id and password.
>
> I thought the function would operate in a similar fashion to a view or
> table-valued function; however, i was mistaken.
>
> This line's error is "Invalid Object Name"..
>
> rdsStr = "SELECT fGrantAccess FROM dbo.fGrantAccess WHERE (" & _
> "(uiLoginId='" & uName.Value & "') AND " & _
> "(uiLoginPw='" & uPass.Value & "'));"
>
> rdsADO.Open rdsStr, Application.CurrentProject.Connection,
> adOpenForwardOnly, adLockReadOnly
>
> ps. i have also tried setting the sql string to
>
> rdsStr = "SELECT fGrantAccess FROM {fn {fGrantAccess('" & uName.Value &
> "','" & uPass.Value & "')}};"
>
> Thank you for your help...



 
Reply With Quote
 
=?Utf-8?B?cm9nZ2U=?=
Guest
Posts: n/a
 
      1st Aug 2007
Baz, that worked like a charm... i need to adjust the rest of my code; but,
hopefully, i will be able to figure that out... have a good week

"Baz" wrote:

> Try this:
>
> rdsStr = "SELECT dbo.fGrantAccess('" & uName & "','" & uPass & "')"
>
> "rogge" <(E-Mail Removed)> wrote in message
> news:72EACE30-140F-40D1-8B2A-(E-Mail Removed)...
> > How do i use a SQL Server Scalar-valued function in MS Access ADP?
> >
> > I have a function "fGrantAccess" in the SQL Server Database and i would

> like
> > to use it in an Access Project. The function returns a GUID from a table
> > depending on two parameters: user id and password.
> >
> > I thought the function would operate in a similar fashion to a view or
> > table-valued function; however, i was mistaken.
> >
> > This line's error is "Invalid Object Name"..
> >
> > rdsStr = "SELECT fGrantAccess FROM dbo.fGrantAccess WHERE (" & _
> > "(uiLoginId='" & uName.Value & "') AND " & _
> > "(uiLoginPw='" & uPass.Value & "'));"
> >
> > rdsADO.Open rdsStr, Application.CurrentProject.Connection,
> > adOpenForwardOnly, adLockReadOnly
> >
> > ps. i have also tried setting the sql string to
> >
> > rdsStr = "SELECT fGrantAccess FROM {fn {fGrantAccess('" & uName.Value &
> > "','" & uPass.Value & "')}};"
> >
> > Thank you for your help...

>
>
>

 
Reply With Quote
 
=?Utf-8?B?cm9nZ2U=?=
Guest
Posts: n/a
 
      1st Aug 2007
Thanks Roy... it worked for me

"RoyVidar" wrote:

> "rogge" <(E-Mail Removed)> wrote in message
> <72EACE30-140F-40D1-8B2A-(E-Mail Removed)>:
> > How do i use a SQL Server Scalar-valued function in MS Access ADP?
> >
> > I have a function "fGrantAccess" in the SQL Server Database and i
> > would like to use it in an Access Project. The function returns a
> > GUID from a table depending on two parameters: user id and password.
> >
> > I thought the function would operate in a similar fashion to a view
> > or table-valued function; however, i was mistaken.
> >
> > This line's error is "Invalid Object Name"..
> >
> > rdsStr = "SELECT fGrantAccess FROM dbo.fGrantAccess WHERE (" & _
> > "(uiLoginId='" & uName.Value & "') AND " & _
> > "(uiLoginPw='" & uPass.Value & "'));"
> >
> > rdsADO.Open rdsStr, Application.CurrentProject.Connection,
> > adOpenForwardOnly, adLockReadOnly
> >
> > ps. i have also tried setting the sql string to
> >
> > rdsStr = "SELECT fGrantAccess FROM {fn {fGrantAccess('" & uName.Value
> > & "','" & uPass.Value & "')}};"
> >
> > Thank you for your help...

>
> Assuming username is the first parameter, and password the second, try
> something like this:
>
> rdsStr = "SELECT dbo.fGrantAccess('" & uName.Value & "', " & _
> uPass.Value & "')"
>
> --
> Roy-Vidar
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling/using a sql server scalar valued function John Microsoft Access Form Coding 0 4th Oct 2010 09:39 PM
Accessing SQL Server Table-Valued Function from Access front-end Arvi Laanemets Microsoft Access 1 16th Apr 2010 08:13 AM
Scalar-Valued UDF Function =?Utf-8?B?R3JlZw==?= Microsoft Access ADP SQL Server 2 21st Sep 2006 05:56 AM
Access SQL Scalar Function DAYOFWEEK Problem =?Utf-8?B?RGVyZWsgQ2hlbg==?= Microsoft Access Queries 1 3rd Dec 2005 11:24 AM
Debuging Scalar-Valued Function in Visual Studio with date parameters Shannon Broskie Microsoft ADO .NET 3 23rd Jul 2004 09:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:26 PM.