473,399 Members | 2,858 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,399 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 6017
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.