Showing posts with label accessing. Show all posts
Showing posts with label accessing. Show all posts

Tuesday, March 20, 2012

Problems with MOD-Function by accessing MS-Access Database via SQL in Delphi

Hello,
the following problem:

I use Delphi 6 to access a MS Access Database.
In short, the Delphi Code looks like this:

ADOConnection1.Open;
ADOQuery1.Close;
ADOQuery1.SQL.Text := 'SELECT * FROM database1 WHERE
value1=1 AND value2= ' + inttostr(array[3]);

ADOQuery1.Open;

Label5.Caption:=ADOQuery1.Fiel*dByName('value4').A sString;

Now I only want to select these rows, where the Integer value3 ends on
1. So I need the Modulo-Function. I found in the Internet these two
functions:
MOD(x,y) und x % y
But I get an error if I want to use one.

For example, If I change

ADOQuery1.SQL.Text := 'SELECT * FROM database1 WHERE
value1=1 AND value2= ' + inttostr(array[3])+' AND MOD(value3,10) = 1;

Delphi shows me a Syntax Error in this statement.

Thx for help!Sorry, there is a ' missing in the code. But it has nothin to do with
the problem:

The first code runs perfectly, but If I insert
AND MOD(20,10) = 0 there is the syntax error again.|||On 23 Aug 2005 11:51:15 -0700, sarah18web wrote:

> Sorry, there is a ' missing in the code. But it has nothin to do with
> the problem:
> The first code runs perfectly, but If I insert
> AND MOD(20,10) = 0 there is the syntax error again.

Don't know what it might have to do with Delphi; but MOD() is not a
function supported by SQL server. Only the % operator works.

Saturday, February 25, 2012

Problems with assembly accessing LDAP & Registry

Running SSRS 2005, I have a custom assembly that needs to read/browse
the file system, Active Directory, and the registry. I have added the
explicit permissions into the code before the calls ie.
Dim fsec As New FileIOPermission(FileIOPermissionAccess.AllAccess,
strFilePath)
fsec.Assert()
Dim perm As New RegistryPermission(RegistryPermissionAccess.Read,
"HKEY_LOCAL_MACHINE\SOFTWARE\0")
perm.Assert()
Dim dsp As New
DirectoryServicesPermission(DirectoryServicesPermissionAccess.Browse,
groupLDAP)
dsp.Assert()
I believe I've added the code group entry for my assembly into the
rssrvpolicy.config file in the correct place (first entry in the group
for the zone=MyComputer.)
<CodeGroup class="FirstMatchCodeGroup"
version="1" PermissionSetName="FullTrust"
Name="MyCustomAssemblyCodeGroup"
Description="A special code group for my custom assembly">
<IMembershipCondition class="UrlMembershipCondition" version="1"
Url="D:\Microsoft SQL Server 2005\MSSQL.3\Reporting Services
\ReportServer\bin\UrixRS.dll"/>
</CodeGroup>
The report runs fine in preview (expected), in debugLocal (great), but
returns errors when it is deployed to the server (rats!) Actually, the
file IO runs OK on the server. It's just the LDAP and registry calls
that die. Some other code that does not use protected resources runs
fine so I'm confident that I brought the assembly into the report
correctly.
I've disabled the CAS security and the report still errors on the
server. I also made sure the web.config file has impersonate="true" so
the machine user_id should be passed (The global User!UserID in RS is
showing correctly on the server report). Anyone have any ideas what
the issue may be?Update. I've gotten the registry access to work. The problem I still
have is that I can't access the LDAP. I believe the root of the
problem has to do with I'm not able to use UNC paths in my assembly or
I get a not found error. It can access c:\myfile.txt fine, but it
can't get to \\myserver\myfile.txt.
As before, everything still works fine locally, it's just when I try
to run off the report server that I have the problem.
Has anyone had similar issues using UNC paths in custom assemblies?

Problems with accessing database remotely

I'm writing an web app in VS2005.

I've created a product.mdf database through VS2005's Server Explorer (to my knowledge, I'm not using Sql Express). (Side question. The .mdf files are a stand alone xml structure used as a database, correct?).

When I execute locally, everything works great. But when I moved my code to where it is being hosted (remote computer). It's throwing the following error:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

This is my connection string:

<addname="MyConnectionString1"connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Product.mdf;Integrated Security=True;User Instance=True"providerName="System.Data.SqlClient"/>

What is my problem?

There is no SQL Server 2005 Express running on the remote server.

Jos

|||

Actually, you ARE using SQL Express. The Visual Studio environment does a great job in hiding this - but behind the scenes a SQL Express database engine is running on your local machine (you can see it in the Services.msc explorer). Your web application is using the web.config connection string tofind this SQL Express database.

As the previous reply says, the error message is due to the application trying to find a SQL Express database engine running on the remote computer and serving a database called Product.mdf.

The solution to your problem may be to install SQL Express on the remote computer. You will then need to copy (attach) the Product.mdf database to the remote database server.

However, if your "remote computer" is actually a hosting provider - they may not (and most don't) support SQL Express - and may insist that you use SQL Server Enterprise instead, which is a far more robust option anyway.

|||

Why I got the error message?

The error message you got was due to the using of SQL Express in your local (development) machine.

Ok, how to solve this issue?

It is easy. Eiteher use SQL Express on your production (e.g. hosting server) [NOT Recommended] or do the following:

Attach your .mdf file to a database (e.g. new database) in the sql server of the hosting company.
Change your ConnectionString to be as following:

<add name="MyConnectionString1" connectionString="Server=YourSqlServerName;Database=MyDatabase;Integrated Security=True;" providerName="System.Data.SqlClient"/>

YourSqlServerName: Type the name of the sql server as provided by the hosting company.

MyDatabase: The database you are using which reside in the hosting company sql server.

Note: The above ConnectionString is used with "Windows Authentication", for the "Mixed Mode" use the following ConnectionString:

<add name="MyConnectionString1" connectionString="Server=YourSqlServerName;Database=MyDatabase;User ID=MyUserID; Password:MyStrongPassword"providerName="System.Data.SqlClient"/>