473,768 Members | 4,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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='12111000 0'
Dim myCommand As New OdbcCommand(myQ uery, myConnection)
Try
myConnection.Op en()
'Dim myReader As OdbcDataReader
'myReader = myCommand.Execu teReader()
'EventLog.Write Entry("Lecture des données effectuées avec succès.")
Catch ex As Exception
'EventLog.Write Entry("Erreur de base de données.")
'Finally
'EventLog.Write Entry("Fermetur e de la base de données.")
myConnection.Cl ose()
End Try

What is my problem ?

Thanks
Jul 21 '05 #1
1 6035
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;US R=dba;PWD=tom")Dim myQuery As String = "SELECT * FROM GL_ANNU WHERE no_gl='12111000 0'Dim myCommand As New OdbcCommand(myQ uery, myConnection)
Try
myConnection.Op en()
'Dim myReader As OdbcDataReader
'myReader = myCommand.Execu teReader()
'EventLog.Write Entry("Lecture des données effectuées avec succès.") Catch ex As Exception
'EventLog.Write Entry("Erreur de base de données.")
'Finally
'EventLog.Write Entry("Fermetur e de la base de données.")
myConnection.Cl ose()
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
1835
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 works fine here in the office however when I try from home for example the application does not work because the credentials do not match. How do I pass the credentials from my .NET windows application to the IIS server running the remoted object....
2
1201
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 SERVICE account in its application pool. I create an object in Global.asax which monitors a folder for upcoming files.What is the security context of the object since there is no user (Domain\Username) requesting this object.Is it running under...
7
2240
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 Access 2002 database backend. The future will require that 1. The database be switched with minimal effort to SQL Server and 2. A Web Application be added to allow web access to reports generated from the database. At this time, there is no...
4
3707
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 from an installed version of the application on another machine. My problem is that I would like to access the database overnight unattended to perform some maintenance tasks. With my fairly limited knowledge of SQL Server and VB.NET, I thought...
1
301
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 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...
0
1291
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 kept on the network drive. If I run the code as a Windows Application I can access the database file. BUt when I run the Windows Service I get following error- "The Microsoft Jet database engine cannot open the file...
4
1134
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 the current system time. If there is a match a program is then started. The apps purpose is be like the windows task scheduler. And I want to run it as service because it will run continuosly. I can't seen to find an example of where an app like...
20
3295
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 many connection has been used ? 2. If the maximum pool size has been reached, what happens when I call the method Open to open the connection ? Will I get an error ? MSDN says the request is queued, but will I get an error in the open method ? ...
6
595
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 process is outside my domain - I can rely on the file being updated when data changes. Within my domain is the design of a Windows service to perform the operations required when the data changes. I have not produced a Windows service before...
0
9575
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9407
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9960
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9842
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8840
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3931
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.