|
Yes, the config file should have the same name, and it should be in the same folder.
|
|
|
|
|
Thanks a lot. That totally helped.
|
|
|
|
|
Hi Guys
I need an urgent help on the below content. I highly appreciate for the help provided, if any.
I am using VS 2008, I am using System.Data.Common namespace to connect to the database server.
I am trying to connect Postgre Database Server.
KINDLY HELP.
It gives me the below error while trying to connect.
System.InvalidOperationException: The 'System.Data.OleDb' provider is not registered on the local machine.
at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at DataAccessLayer.IHTPLDataAccess.OpenConnection() in C:\Documents and Settings\sunpa\Desktop\ProjectTesting\CL\ErrorMessage-24042010\DataAccessLayer\classes\IHTPLDataAccess.cs:line 159
The code is below:-
DbConnectionStringBuilder connectionStringBuilder = new DbConnectionStringBuilder();
connectionStringBuilder.Add("User Id", _userID);
connectionStringBuilder.Add("Password", _password);
connectionStringBuilder.Add("Provider", "System.Data.OleDb");
connectionStringBuilder.Add("location", _dataBase);
connectionStringBuilder.Add("Data Source", _serverName);
connectionStringBuilder.Add("timeout", "1000");
DbConnection _connectionObject = null;
DbProviderFactory factoryObject = null;
factoryObject = DbProviderFactories.GetFactory(_DBProvider);
_connectionObject = factoryObject.CreateConnection();
_connectionObject.ConnectionString = connectionStringBuilder.ToString();
_connectionObject.Open(); // This give me error as below
System.InvalidOperationException: The 'System.Data.OleDb' provider is not registered on the local machine.
at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at DataAccessLayer.IHTPLDataAccess.OpenConnection() in C:\Documents and Settings\sunpa\Desktop\ProjectTesting\CL\ErrorMessage-24042010\DataAccessLayer\classes\IHTPLDataAccess.cs:line 159
Pradeep Sen
Senior Developer
Mumbai
India
modified on Saturday, April 24, 2010 3:16 AM
|
|
|
|
|
You old the OleDb Connection object that the Data Provider was "System.Data.OleDb". That's not a data provider. That's a namespace in the .NET Framework.
I think the provider your looking for is called "PostgreSQL OLE DB Provider". I've never used PostGre before, so I don't know for sure.
|
|
|
|
|
Hi Dave
Thanks for your input.
Actually I am trying to make a data connection class independent of database vendors.
Now If the Provider is not System.Data.OleDb and something like "PostgreSQL OLE DB Provider", then how can I make it generic which the developer will like to use only System.Data.OleDb to connected to other databases like DB2 or Oracle (thou we have a namespace in .Net for oracle, still u can use System.Data.OleDb)
Thanks for you valuable time.
ANY ONE ELSE THERE WHO CAN HELP OUT
Regards
PS
Pradeep Sen
Project Manager
Kunming
China
|
|
|
|
|
You'd have to let the developer supply you with the DataProvider name or supply the connection object to your code.
Pradeep Sen wrote: thou we have a namespace in .Net for oracle, still u can use System.Data.OleDb
Yep, and by using OleDb, you also lose any optimizations specifice to that provider costing you speed and flexibility.
If it were me, I'd probably supply data layers for specific databases, like Oracle, SQL Server, and Access, then let the developer write their own data layer classes using the interfaces you provide to do so.
|
|
|
|
|
Hi Dave
Thanks for your suggestions.
I was looking to avoid writing different datalayers.
Is there anyway, I can use Postgre using the system.data.common?
Else, I have to take up the layered scope.
Thanks in advance
Regards
Ps
Pradeep Sen
Project Manager
Kunming
China
|
|
|
|
|
The classes found in Common are for writing your own DataProviders. You can read a bit on the subject here [^] (registration is free).
|
|
|
|
|
Does anyone know if it's possible program with .net 4.0 from Visual Studio 2008?
If so, how?
I've already installed .net 4.0 on my computer, but when I when to set the target framework under the project's properties, I can only go up to 3.5. Upgrading to Visual Studio 2010 is out of the question because this is a team porject on multiple machines, and we would have to get licences for all the machines the team is using when we already have licences for 2008.
|
|
|
|
|
You can't target .NET 4 from Visual Studio 2008. What you could do is code your application up in VS2008 and then compile it manually using the .NET 4 compiler directly.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Visual Studio 2008 can only target .NET Framework 3.5, 3.0, or 2.0. Visual Studio 2010 can target 2.0, 3.0, 3.5, 3.5 Client Profile, 4.0, or 4.0 Client Profile and includes an ability to target additional framework releases in the future.
You can install Visual Studio 2010 side-by-side with Visual Studio 2008.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Which makes me think it may be possible to hack VS 2008 to use .net 4. (Not that I want to, other than as an exercise, mind you.)
|
|
|
|
|
I think it is a hard-coded list, which would mean it's not possible. In VS2010, when you click the link for "more Frameworks" it simply takes you to the download page for the .NET Framework.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Yes, but I had some minor success in trying to trick VS 2008 into thinking that v4 is actually v3.5. It looks like it's mostly a matter of configuring MSbuild.
|
|
|
|
|
No, it's not. You can either use VS2010 or the command line compilers without Visual Studio.
|
|
|
|
|
fct2004 wrote: Does anyone know if it's possible program with .net 4.0 from Visual Studio 2008?
Nope.
You cannot run Silverlight 4 either.
|
|
|
|
|
And you only get the new version of GACUTIL by installing VS 2010.
|
|
|
|
|
Hi, I've been trying to figure out how to send commands for a printer installed in a USB port. Previously I could do this with the LPT1 port by calling kernel32.dll CreateFile method (DLLImport) and sending the commands this way. But with USB ports this doesn't work.
So does anybody know how to do that? Or at least have any article on that matter, I couldn't find anything (sorry if its easy to find, I just suck at finding stuff).
So my requirement is, cycle through USB ports to check if there is any device attached. If there is a device attached, send a command to ask the device to identify itself.
So basically I'll need two things, learn to dynamically cycle through USB port, send commands to it and read the responses.
All of that using C# and .Net Framework 2.0.
Any ideas?
Thanks in advance for any help. Regards,
Fábio
modified on Saturday, April 24, 2010 9:44 AM
|
|
|
|
|
|
That's great!!! For now you solved my needs. But soon I will also need to read from it. Hopefully I'll figure out on my own, studying the code and the spooler usage. Anyway, thanks a lot.
And thank for clearing it about the fact that USB port is not really a port. 5!
|
|
|
|
|
Reading from a printer? That's not going to happen by studying that code I kinked to.
Then again, you haven't said WHAT you think your going to read or why you need it.
|
|
|
|
|
Sorry for that. Let me clear it out. I need to talk to the printer because it's a Zebra printer with RFID capability. What I will do is send ZPL commands to the port and read the response. Zebra receives ASCII commands and responds with ASCII too.
There are several uses for the printer's responses, including telling the success of a RFID TAG write operation.
Perhaps I will need another alternative to the spooler API to acomplish that.
Thanks again for your help.
|
|
|
|
|
Yep. The spooler will not return anything to you. This kind of printer should have an SDK available from the manufacturer, making all of the code you just got moot.
|
|
|
|
|
Yeah, I wish it did. I contacted Zebra and they don't have anything for .Net yet. They should have in the near future, but couldn't give any dates. And I need it now. That's why I was asking for a way to talk to the BUS, no matter the device. And if I get that, I'll also be able to use to talk to the fingerprint reader from Microsoft on another project of mine, which seems there is no SDK either, just the drivers.
Thanks for your help
|
|
|
|
|
Fabio Franco wrote: That's why I was asking for a way to talk to the BUS, no matter the device.
There's no such thing on USB. You have no choice but to talk to the DEVICE on the bus. You cannot treat the USB port like it was a serial or parallel port. That's like trying to communicate to a card inserted into an expansion slot on the motherboard by talking to the slot it's plugged into. You can't do it.
If they don't have a .NET specific library, you've going to have to make do with either normal C-style library and P/Invoke the functions or, hopefully, they have a COM-based library that you can use. Just because they don't support .NET directly does not mean that your out of luck. It's just going to take more work.
|
|
|
|
|