473,385 Members | 1,292 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Question about Windows service to access Database

Hi

I try to create a windows service to read content of my database at
each 60 minutes. I create my service, i put a timer and set it's
interval to 600000. This work good. My problem is that when I access
my database. It seem that I can't open my database. Hre's my code :

Dim myConnection As New OdbcConnection("DSN=pg_dem;USR=dba;PWD=tom")
Dim myQuery As String = "SELECT * FROM GL_ANNU WHERE no_gl='121110000'
Dim myCommand As New OdbcCommand(myQuery, myConnection)
Try
myConnection.Open()
'Dim myReader As OdbcDataReader
'myReader = myCommand.ExecuteReader()
'EventLog.WriteEntry("Lecture des données effectuées avec succès.")
Catch ex As Exception
'EventLog.WriteEntry("Erreur de base de données.")
'Finally
'EventLog.WriteEntry("Fermeture de la base de données.")
myConnection.Close()
End Try

What is my problem ?

Thanks
Jul 21 '05 #1
1 6016
Is the DSN a User DSN or a System DSN? If it's a User DSN
it is only available to the currently logged on user.
Probably your service runs under different credentials
than the ones you are logged on with.

Resolution: create the DSN as a System DSN, or what I
prefer is to use DSN-less connection strings. A DSN-less
connection string specifies everything that's needed to be
configured in the connection string, such as DRIVER (ODBC
driver that is used) as well as all specific properties
for your ODBC driver. You can store the connection string
in a configuration file (perhaps encrypted for increased
security).
-----Original Message-----
Hi

I try to create a windows service to read content of my database ateach 60 minutes. I create my service, i put a timer and set it'sinterval to 600000. This work good. My problem is that when I accessmy database. It seem that I can't open my database. Hre's my code :
Dim myConnection As New OdbcConnection ("DSN=pg_dem;USR=dba;PWD=tom")Dim myQuery As String = "SELECT * FROM GL_ANNU WHERE no_gl='121110000'Dim myCommand As New OdbcCommand(myQuery, myConnection)
Try
myConnection.Open()
'Dim myReader As OdbcDataReader
'myReader = myCommand.ExecuteReader()
'EventLog.WriteEntry("Lecture des données effectuées avec succès.") Catch ex As Exception
'EventLog.WriteEntry("Erreur de base de données.")
'Finally
'EventLog.WriteEntry("Fermeture de la base de données.")
myConnection.Close()
End Try

What is my problem ?

Thanks
.

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Nicholas Then | last post by:
I am writing an application that uses Remoting that is hosted within IIS. We have an SSL cert enabled on the server. We are using windows authentication on this remoting service. Everything...
2
by: J-T | last post by:
We have an asp.net application with <identity impersonate="true"/> and <authentication mode="Windows" /> in our web config and we are using Windows integrated in IIS and also NT AUTHORITY\NETWORK...
7
by: News | last post by:
Hello, I have to build a program with the future in mind and I need a bit of guidance from a guru or two. My program will start as a multi-user Windows Application built with VB.Net and using an...
4
by: Andy Baker | last post by:
I have an Windows forms application written in VB.NET that uses a SQL Server 2000 back end database with Windows authentication. There is no problem accessing the database from my application, or...
1
by: Eric Caron | last post by:
Hi I try to create a windows service to read content of my database at each 60 minutes. I create my service, i put a timer and set it's interval to 600000. This work good. My problem is that...
0
by: dinoo | last post by:
I did not find the right forum to post this issue, please excuse me for this. But I need the help here very badly. I am having a Windows Service in .NET which is accessing a MDB file which is...
4
by: Gordon | last post by:
Hi; I have developed a VB.net app in a module that queries a database, loads the data into several arrays and then loops through the array. It then compares time data stored in the array with...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
6
by: Chris Marsh | last post by:
All I have a database table, changes to the data within which I am interested in acting on. The approach that I'm taking is to have the database update a file every time data is updated. This...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.