IIS5 - ODBC - Data source name not found and no default driver specified - visual-studio-2005

I’ve got some problem using an ODBC connection with IIS.
Here is my config :
IIS 5 on Windows XP
ASP.NET 2.0
Oracle 9
VS 2005
When I try too use my web application on IIS, I’ve got the following exception:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
BUT, when I use it like a web site in VS2005, I didn’t have any error.
So, I’d try to make a very little app, with the following code:
using System;
using System.Data;
using System.Data.Odbc;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OdbcConnection con = new OdbcConnection();
con.ConnectionString = "DSN=<MyDSN>;Uid=<LOGIN>;Pwd=<PASSWORD>";
IDbCommand com = new OdbcCommand();
com.CommandText = "select sysdate from dual;";
com.CommandType = CommandType.Text;
com.CommandTimeout = 30;
com.Connection = con;
try
{
con.Open();
Response.Write(com.ExecuteScalar());
}
finally
{
if (con.State == ConnectionState.Open)
con.Close();
}
}
}
It work fine on VS’s web server (ie: http://localhost:3715/Web/Default.aspx), but I’ve got the same exception (IM002) when I use it on IIS (ie: http://localhost/Tester/default.aspx).
My DSN is declared on the “ODBC Data Source Administrator” and work well when I test the connection…
The ASPNET account is in the same group as my user account (Administrators).
Full right for ASPNET Account on HKEY_LOCAL_MACHINE\SOFTWARE\ODBC and
HKEY_CURRENT_USER\Software\odbc keys.
I've read this post, but nothing work...
I'd look after an answer on stackoverflow (search, related questions, etc.), google...but I didn't found a working solution...
Is there anyone who have an idea?...
Where is my mistake?...
UPDATE: 2011/04/06
What I’ve done so far:
Tracing for ODBC: on VS’Web server, I got log; but on IIS, none...
System and User DSN are filled with the same information
Allow ASPNET, IUSR_XXX, IWAN_XXX, and all users (sic…) accounts full rights to: %ORACLE_HOME%, HKEY_LOCAL_MACHINE\SOFTWARE\ODBC, HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
Windows, VS and IIS are all for 32 bits (so, there is no c:\windows\syswow64).
Check PATH value, and put %ORACLE_HOME% first.
IIS was reset each time I do a modification, my computer reboot twice.
But, now, I’ve got this message:
ERROR [IM003] Specified driver could not be loaded due to system error 998 (Oracle dans OraHome92).
And I finally found...
The administrators have install all the drivers in order to be used by the user only...
I’d create a system env var ORACLE_HOME...
There was only a user var :s
Thanks for your help.
I validate the Garry M. Biggs' answer because of the difference between system/user...

Had this problem ..
The best solution is to re install your odbc driver ... worked for me ..
the registry entries in your system might have got tampered .
I did a complete uninstall and re install .. worked for me .. lame but quick solution .

Make sure you have created a System DSN rather than a User DSN.
IIS will be running as a System service and therefore does not have access to User registry entries...

Maybe your system is 64 bit version
of Windows and IIS is 64 bit, but VS
is 32 bit? If so, look at my
answers:
odbc connection string dosen't work on windows 7
If you can connect from one environment and not from the other then enable ODBC tracing and compare log files. MS described it at: http://support.microsoft.com/kb/274551

Related

Wifi WPS client start in Windows 10 in script or code

I can not find how to start WPS client in Windows 10 from command prompt or powershell. When I used Linux, everything was really ease with wla_supplicant (wpa_cli wps_pbc). Is there something similar in Windows?
Does anyone know how to set up Wi-Fi network (over WPS) key without human input in Windows?
I also tried WCN (Windows Connect Now) from Microsoft as it implements WPS features. I got also samples from Windows SDK on WCN, but they could not get key by WPS (it faild). But if I use Windows user interface to connect wiothout PIN, everyting seems to be pretty fine.
I am sure that there is possibility to do that, it is very important to perform Wifi Protected Setup by button start from the command prompt or app (C++/C#) without human intrusion or input (once WPS is on air, Windows should automatically get the network key and connect then).
I don't know if it's too late to answer, just put what I know in here and hope it can help.
First, if your system has updated to 16299(Fall Creator Update), you can just simply use new wifi api from UWP.
Install newest Windows SDK, create a C# console project, target C# version to at least 7.1, then add two reference to the project.
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd
After all of that , code in below should work.
using System;
using System.Threading.Tasks;
using Windows.Devices.Enumeration;
using Windows.Devices.WiFi;
class Program
{
static async Task Main(string[] args)
{
var dic = await DeviceInformation.FindAllAsync(WiFiAdapter.GetDeviceSelector());
if (dic.Count > 0)
{
var adapter = await WiFiAdapter.FromIdAsync(dic[0].Id);
foreach (var an in adapter.NetworkReport.AvailableNetworks)
{
if (an.Ssid == "Ssid which you want to connect to.")
{
// Fouth parameter which is ssid can not be set to null even if we provided
// first one, or an exception will be thrown.
await adapter.ConnectAsync(an, WiFiReconnectionKind.Manual, null, "",
WiFiConnectionMethod.WpsPushButton);
}
}
}
}
}
Build and run the exe, then push your router's button, your pc will be connect to the router.
But if you can not update to 16299, WCN will be your only choice. You may already notice that if call IWCNDevic::Connect frist with push-button method, the WSC(Wifi Simple Configuration) session will fail. That's because WNC would not start a push-button session as a enrollee, but only as a registrar. That means you have to ensure that router's button has been pushed before you call IWCNDevic::Connect. The way to do that is using Native Wifi api to scan your router repeatedly, analyse the newest WSC information element from the scan result, confirm that Selected Registrar attribute has been set to true and Device Password Id attribute has been set to 4. After that, query the IWCNDevice and call Connect function will succeed. Then you can call IWCNDevice::GetNetworkProfile to get a profile that can use to connect to the router. Because it's too much of code, I will only list the main wifi api that will be used.
WlanEnuminterfaces: Use to get a available wifi interface.
WlanRegisterNotification: Use to register a callback to handle scan an connect results.
WlanScan: Use to scan a specified wifi BSS.
WlanGetNetworkBsslist: Use to get newest BSS information after scan.
WlanSetProfile: Use to save profile for a BSS.
WlanConnect: Use to connect to a BSS.
And about the WSC information element and it's attributes, you can find all the information from Wi-Fi Simple Configuration Technical Specification v2.0.5.
For Krisz. About timeout.
You can't cast IAsyncOperation to Task directly. The right way to do that is using AsTask method. And also, you should cancel ConnectAsync after timeout.
Sample code:
var t = adapter.ConnectAsync(an, WiFiReconnectionKind.Manual, null, "",
WiFiConnectionMethod.WpsPushButton).AsTask();
if (!t.Wait(10000))
t.AsAsyncOperation().Cancel();

How can I connect to Oracle DB using Sahi 5.0 OS

I'd like to connect to Oracle Database using Sahi 5.0 OS API:
var $db = _getDB($driver, $jdbcurl, $username, $password)
or
var $db = _getDB("oracle.jdbc.driver.OracleDriver",
"jdbc:oracle:thin:#dbserver:1521:sid",
"username", "password");
I have downloaded classes12.jar and ojdbc14.jar and put it in C:\Users\Username\sahi\extlib\db
I've also already added in dashboard.bat:
set SAHI_CLASS_PATH=%SAHI_HOME%\lib\sahi.jar;
%SAHI_HOME%\extlib\rhino\js.jar;%SAHI_HOME%\extlib\apc\commons-codec-1.3.jar;
%SAHI_HOME%\extlib\db\ojdbc14.jar;%SAHI_HOME%\extlib\db\classes12.jar
and in dashboard.sh:
SAHI_CLASS_PATH=$SAHI_HOME/lib/sahi.jar:$SAHI_HOME/extlib/rhino/js.jar:
$SAHI_HOME/extlib/apc/commons-codec-1.3.jar:
$SAHI_HOME/extlib/db/ojdbc14.jar:$SAHI_HOME/extlib/db/classes12.jar
However if I try use 1st method to use _getDB i've following result:
Java constructor for "net.sf.sahi.plugin.DBClient"
with arguments "string,string,string,string" not found.
When I use second one I have this:
Java constructor for "net.sf.sahi.plugin.DBClient"
with arguments "string,string,java.util.Properties" not found.
How connect I connect to Oracle DB and use methods like $db.select and $db.update?
I'm working on Windows 7 with JDK 1.8
I think I can help you.
Was also getting errors when trying to connect to a database with Sahi OS.
The examples shown in https://sahipro.com/docs/sahi-apis/database-apis.html page are useful, but I believe there is more to the SAHI Pro.
Because I said it above?
I tried a number of ways and was not loading the database. Another problem is that I was trying to insert and not recover data.
I began to analyze the obtained error (same as yours) and then found that the SAHI API, this class 'net.sf.sahi.plugin.DBClient', there is the constructor method in the class, the _getDb function () calls to start the object.
Concludes that it found the SAHI API available on Github and checked by the class.
There is no method builder, this function does not work for SAHI OS.
So we have to do this using functions of the JAVA language, as is the example: https://sahipro.com/docs/sahi-apis/database-apis.html#Accessing%20databases%20directly
I modified this function (as I said, I was entering in the database) to my need, which was inserted into the database and vualá !!!! It worked!
I used SQLite (the SAHI documentation contains no example)
To clarify, the function I created would be this:
function setRawDB(driverName, jdbcurl, sqlQuery) {
java.lang.Class.forName(driverName);
var connection = java.sql.DriverManager.getConnection(jdbcurl);
var stmt = connection.createStatement();
var query = stmt.executeUpdate(sqlQuery);
stmt.close();
//sahi auto commit
//connection.commit();
connection.close();
}
and then I got to use automated scripts (before I was just getting used testing directly on the page), saving directly in the local database.
Only in this way could use.

Database access issue with Visual Studio application

I has been created a program that works with MS Access 2010 (.accdb)extension. The program is fully works fine.
The issue is:
When the program is installed into another PC that has no MS Office installed, then the Exception that defined in the program returns connection error. Yes of course because the program can't read the (.accdb) file without office installed.
Need solution:
Is there any way to import this (.accdb) in order to read and modify it. Or is there any other simple solution that works when the application is installed to any non office installed PC?
The Demo of My program Code is:
Connection String:
Imports SpeechLib
Imports System.IO
Module MdlIPray5ve
Public con As OleDb.OleDbConnection
Public cmd As OleDb.OleDbCommand
Public sql As String
Public speaker As New SpVoice
Public Function connection() As String
Try
connection = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=azan_time.accdb; Persist Security Info=False;"
Catch ex As Exception
MessageBox.Show("Could not connect to the Database. Check your Connection!")
End Try
End Function
Something that Accesses the Database:
Private Sub UpdateAlarmTone()
Try
Dim cmdText = "UPDATE alarm_tone SET subhi= #subhi1, zuhur =#zuhur1, aser = #aser1, megrib = #megrib1, isha = #isha1"
Using con As New OleDb.OleDbConnection(connection)
Using cmd As New OleDb.OleDbCommand(cmdText, con)
con.Open()
cmd.Parameters.AddWithValue("#subhi1", txtSubhi.Text)
cmd.Parameters.AddWithValue("#zuhur1", txtZuhur.Text)
cmd.Parameters.AddWithValue("#aser1", txtAser.Text)
cmd.Parameters.AddWithValue("#megrib1", txtMegrib.Text)
cmd.Parameters.AddWithValue("#isha1", txtIsha.Text)
Dim infor As String
infor = cmd.ExecuteNonQuery
If (infor > 0) Then
MsgBox("Alarm Tone record updated successfuly")
Else
MsgBox("Update failed!")
End If
End Using
End Using
Catch ex As Exception
MessageBox.Show("There is a problem with your connection!")
End Try
End Sub
create the Access database via ODBC, that comes with Windows itself.
You can also use other databases (eg., MySQL, Firebird, SQLite, and others) that are available that wouldn't necessarily cost your client anything if they installed it (or, for some, if you included it in your installation for them).
Using the MS Office COM automation requires that the MS Office product be installed on the machine running the automation.
There are third-party code libraries that replace that functionality with their own code, meaning your app could create it's own Access-compatible files. However, your users would still need Access to use them

How to deploy Entity Framework with Oracle ODAC 12 on WS2012 just copying DLLs

I´ve searched the following links:
How to deploy Oracle with EF
Problems deploying Oracle with EF
And many other posts around regarding Oracle deployment.
Basically I have an C# simple test application to insert some rows into a database (this is a test application. The full application uses a lot of EF stuff):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
using MzDbLib.DataAccessObject;
using MzDbLib.DatabaseContext;
using MzDbLib.DatabaseModel;
namespace TestDbConnection
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This program will generate 10 logs into SYSTEMDATALOG table");
///
/// Do a loop of 10 logs generated
///
for (int i = 0; i < 10; i++)
{
string msg = "TEST GENERATED LOG NUMBER " + i.ToString();
Console.Write("Generating log " + i.ToString() + "...");
//
// Connect to database and to the log table
//
Entities dbContext = new Entities();
SYSTEMDATALOG logTable = new SYSTEMDATALOG();
logTable.DATETIME = DateTime.Now;
logTable.TYPE = "INFO";
logTable.SEVERITY = 0;
logTable.SOURCE = "TESTDBCONNECTION";
logTable.USER = "SYSTEM";
logTable.MESSAGE = msg;
dbContext.SYSTEMDATALOG.Add(logTable);
dbContext.SaveChanges();
Console.WriteLine("Done.");
}
Console.WriteLine ("Data generated at the database. Press a key to end test.");
Console.ReadKey();
//
// Application exit
//
Environment.Exit(0);
}
}
}
The dbContext and SYSTEMDATALOG classes were generated though EF model-first from an Oracle database. I´m using Visual Studio 2012 and ODAC 12.1.0.1.0 with Oracle Developer Tools 32-bit installed on development machine. All fresh install and working pretty fine when developing.
All runs fine in DEVELOPMENT, but neve in production.
I´m using in production WINDOWS SERVER 2012. I have tried the following approaches:
a) Install WS2012 from schatch and install ODAC 32-bit version 12.1.0.1.0 fresh from Oracle site. I did run install
with ODAC 4 version.
I got "The provider is not compatible with the version of Oracle client". After some tries and some hours lost, with different approaches, I decided to go to a new method - non-installating Oracle
b) I fresh installed WS2012 and did no ORacle installation. Copied the DLLs stated in the above links and now I´m getting "Unable to find the requested .NET data provider". I´ve copied all the available Oracle DLLs from DEV machine to the WS2012 EXE directory of my application and still getting that error.
My connection string (auto-generated by VS2012) is:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/DatabaseModel.DatabaseModel.csdl|res://*/DatabaseModel.DatabaseModel.ssdl|res://*/DatabaseModel.DatabaseModel.msl;provider=Oracle.DataAccess.Client;provider connection string="data source=//ORACLESERVER1:1521/MEZAMES;password=xxx;persist security info=True;user id=MZMESDB"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
This string is being generated into 2 files: TestDbConnection.exe.config and TestDbConnection.vshost.exe.config (I´m copying the bin/Debug folder to the server).
So, I need help to deploy my app to the new server. Some questions:
a) Which DLL is needed to go with the application for ODAC 12.1.0.1 ? Does that changed from ODAC 11 ?
b) Is that last error regarding EF or Oracle ?
c) Why does VS generated 2 config files ?
d) Does "providerName="System.Data.EntityClient" is the cause of the error ? If so, what DLL should be copied together.
e) Is there any tool/way to know what´s missing or with incompatible version, avoiding copying and trying methods ?
f) Is something missing on the config file ?
Thanks all for any kind of help. This is making me crazy as I´m stuck on that since the beggining of the week...
I'm not sure about the installation options for ODAC in a server environment. I know you need the Transaction module only if you're using TransactionScope in your code.
The problem you're seeing from not being able to find the provider is because Oracle changed the provider name from Oracle.DataAccess.Client to Oracle.ManagedDataAccess.Client with the 12c bits.
You need to change this in both the connection strings and in the SSDL section of the EDMX file: you will go from
<edmx:StorageModels>
<Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.DataAccess.Client" (...)
to
<edmx:StorageModels>
<Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.ManagedDataAccess.Client" (...)

Umbraco - First run - connection string failed

I just downloaded Umraco (via Web Platform Installer).
It takes me to this web page:
How can I just select 'integrated security'?
That connection string is set to a blank database that exists. I have added 'IIS AppPool\DefaultAppPool' and 'IIS APPPOOL\UmbracoTest' as database owner. The next screen is like this Database configuration is invalid for connection string Data Source=.;Integrated Security=True;Initial Catalog=UmbracoTest:
That connection string is fine, I've used '.' datasource elsewhere with no problems (SQL Express).
Is there any way to get useful error messages?
How can I get this working?
Thanks.
I just ran into the same issue during an Umbraco 6.1.5 installation. My issue was the providerName being empty as suggested, so when I added:
providerName="System.Data.SqlClient"
I was able to install and upgrade my Umbraco 6.1.3 database. My full connection string is:
<add name="umbracoDbDSN" connectionString="server=72.18.**.***,1533;database=mydatabase;user id=emma;password=******" providerName="System.Data.SqlClient" />
The connection string is wrong, trust me :)
Instead of DataSource=. try DataSource=.\sqlexpress
Also ensure that the initial catalog=UmbracoTest is actually the correct name of the database.
Finally, since you are using an Umbraco 6.x version, the log files will be at ~App_Data/Logs but in this case they will just tell you much the same as the install screen, that an SqlException has occurred.
Edit:
Looking at the Umbraco source, the error you see is raised by the following code:
if (_configured == false ||
(string.IsNullOrEmpty(_connectionString) ||
string.IsNullOrEmpty(ProviderName)))
{
return new Result
{
Message =
"Database configuration is invalid. Please check
that the entered database exists and that the provided
username and password has write access to the
database.",
Success = false,
Percentage = "10"
};
}
So my assumption is that you are missing the Provider from your connection string. In your web.config file your connection should look like this:
I had the same issue. I fixed it by adding the IIS_IUSRS user to the Umbraco site directory with "Modify" rights as the setup process is trying to write to the web.config with your connection string. Hope this helps.

Resources