MSDataShape {Class not registered error} in Classic ASP - asp-classic

I am trying to build a datagrid in Classic ASP. I have read a few articles here and there and am trying to use MSDataShape to implement this.
I have never worked with MSDataShape, so have absolutely no idea about it.
'Create the ADO Connection object.
set oCon = Server.CreateObject("ADODB.Connection")
'--- Generate the connection string
sCon = "Data Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;"
sCon = sCon & "Data Source=" & Server.MapPath("Northwind.mdb")
oCon.ConnectionString = sCon
'--- Specify that we will use the Data Shaping provider.
oCon.Provider = "MSDataShape"
'--- Open the connection
oCon.Open
I get the following error:
Microsoft OLE DB Service Components error '80040154' Class not
registered /DG/test.asp, line 39 –

The error message indicates that the data provider you specified can't be found. In this case, 3.51 is a very old version of Jet. Try using the following:
sCon = "Data Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;"
Also, if you're on a 64-bit OS, make sure you configure your application pool to run in 32-bit mode.

Related

ConnectionString is incorrect in axapta

I want to connect to the other database using LoginProperty class. I did it in two different ways:
Create a DNS system object, using loginProperty class and connect to the DB. This way it works fine.
In the other way, i wants to creat a 'Connection String' and connect to the DB. In this way i am getting an error.
ODBC operation failed. Unable to logon to the database.
[Microsoft][ODBC Driver Manager] Data source name not found and there is no standard driver.
My Connection string is:
connectionString = "Driver={SQL Server Native Client 10.0}; Server=MSS2008-term\\\\SQLServer; Database=db; user ID=sa; Password=ABC.123";
loginProperty.setOther(connectionString);
conn = new ODBCConnection(loginProperty);
What is missing in the connection string?
Try using a raw string assignment (so no \ magic):
connectionString = #"Driver={SQL Server Native Client 10.0}; Server=MSS2008-term\SQLServer; Database=db; user ID=sa; Password=ABC.123";
Some others have problems, see ODBC connection to external data.
Maybe you can create the DSN by code, see What is the simplest, most maintainable way to create a SQL Server ODBC Data Source?
I notice you have Server and Database in your connection string where I use Data Source and Initial Catalog for some reason. You can do it like this, just changing/adding relevant parameters:
public str getConnectionString() {
System.Data.SqlClient.SqlConnectionStringBuilder dbConnectionStringBuilder;
dbConnectionStringBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder();
dbConnectionStringBuilder.set_Item('Data Source', 'YourServer');
dbConnectionStringBuilder.set_Item('Initial Catalog', 'YourDatabase');
dbConnectionStringBuilder.set_Item('Integrated Security', true);
return dbConnectionStringBuilder.ToString();
}

OLEDB connection

Im coonecting to access database using the below connection string :
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\Sally\\Documents\\Visual Studio 2010\\Projects\\StudentsApplication\\StudentsApplication\\School\\School.accdb";
but it's giving me an error Unrecognized database format. is the connection string wrong?
Try with this ,
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;
You should probably add "" around the path:
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"C:\\Users\\Sally\\Documents\\Visual Studio 2010\\Projects\\StudentsApplication\\StudentsApplication\\School\\School.accdb\"";
Take a look a this site, it has examples for all kinds of databases connection strings:
Connection String Home Page
The reason would be that the ACE provider for Microsoft Access is not installed.
Does your system has Office 2007? Its installed normally with Office 2007.
If no, please install and download Office 2007 Data Connectivity Components
Read this: http://social.msdn.microsoft.com/forums/en-US/Vsexpressvb/thread/2a658b68-49c9-448e-8aca-778c1573ffaa/

ASP.NET ERROR : Keyword not supported: 'provider'

My app fails at this line of code:
Dim objConnection As New SqlConnection(Application("ConnString"))
My connection string is:
"Server=testAITSQL;Database=SSCommerce;UID=PlanoWebApp;PWD=XXXXXXXX;"
I googled this problem and the solution for it was having a malformed connection string where the "provider" was being specified when it shouldn't have. Example conn string:
Provider=SQLOLEDB.1;Integrated Security=SSPI;DATABASE=APInquiry;SERVER=SqlServer
I'm not specifying the Provider so I think I have a different problem...???
Does your test server have the exact same configuration file as your development machine? I suspect the configuration file on your test machine may have a different set of values for ConnString than you are expecting.
Provider=xxxx is not a valid .net connection string token.
You are already implicitly specifying the provider by instantiating a SqlConnection.
Drop the provider pair and you will be golden.
maybe, for sh!7s and giggles, try Application("ConnString").tostring
You are connecting to a SQL Server, right?
My ConnString has the following options:
Server
Database
User ID
Password

ASP.NET OLEDB code breaks when deployed on IIS7

I'm trying to write a simple website (ASP.NET v4), which will call Windows Search, find a specific file and return it to the user. I've put together the following as an example: it calls the Windows Search service on "remoteserver", and returns the path of "somefile.txt":
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';";
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = string.Format(
"SELECT System.ItemPathDisplay, System.ItemType FROM " +
" sytelhp.systemindex WHERE SCOPE='file://remoteserver/archive' AND CONTAINS(\"System.FileName\", " +
" '\"*{0}*\"')", "somefile.txt");
conn.Open();
OleDbDataReader rdr = cmd.ExecuteReader();
string result=rdr[0].ToString();
.. and this works great on Visual Studio 2010 development environment, "result" contains the path to the file. However, if I deploy it to the local IIS7 server (running on Server 2008), I get this error:
The parameter is incorrect.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: The parameter is incorrect.
I'm at a loss where to go next. What do I need to do to IIS7, or the code, or both to get it working? Again, this works fine within VS2010 (tested on both Windows 7 and Windows 2008 Server).
I guess you are running on Vista or older OS and the IIS runs on 2008 Server or newer?
Try Provider=Search.CollatorDSO.1 (note the .1).
Edit: You should use a different user account for the search to work (not the default "network service" one the asp.net app runs under). See the comments for more info.

What's wrong with this ASP connection string?

I'm at the end of my rope on this. It should be so simple.
I just need to know what's wrong with this connection string:
dbc.open ("Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; " "User ID = Username; Password = Password;")
I get this error when running that line:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I know ServerName is up and accepting connections, I know InitialDB exists, I know User ID and Password are valid for the database. What am I missing?
In notepad create file anyname.udl - let it be empty. After in explorer click it - you will get a dialog to create OLEDB connection string, select expected driver, and all connection param, ensure that "Allow saving password" = True. Press Ok.
Then again open file with notepad. Content is valid connection string
Try this...
dbc.open ("Provider=SQLOLEDB; Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; User ID = Username; Password = Password; Network Library=dbmssocn;")
As someone has already pointed out, udl is the best easiest way to create a conn string - here is a link that talks about it. https://web.archive.org/web/20210211044624/http://www.4guysfromrolla.com/webtech/070400-1.shtml
If you are using ADOdb you might want to try
"Provider=SQLNCLI10;Server=SERVER;Database=DATABASE;Uid=USERNAME;Pwd=PASSWORD"
for SQL Server 2008 Native Client or
"Provider=SQLNCLI;Server=SERVER;Database=DATABASE;Uid=USERNAME;Pwd=PASSWORD"
for SQL Server 2005 Native Client.
For ODBC, use
"Driver=SQL Server Native Client 10.0"
for SQL Server 2008 Native Client or
"Driver=SQL Native Client"
for SQL Server 2005 Native Client.
What's with the " " in the middle of the string?
Your connection string appears to be mixing ODBC and OLEDB. I would suggest visiting http://www.connectionstrings.com/ and finding the correct syntax for the desired provider.
Yours:
"Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; " "User ID = Username; Password = Password;"
ODBC:
"Driver={SQL Server};Server=ServerName;Database=InitialDB;Uid=Username;Pwd=Password;"
OLEDB:
"Provider=sqloledb;Data Source=ServerName;Initial Catalog=InitialDB;User Id=Username;Password=Password;"
Do you have visual studio?
Connect to the database server, and locate the database you want to connect to.
Right click, select properties. Your connection string to the db is right there.
Copy to wherever you want. -- Should be in web config, but you can paste it directly into code if you so desire.

Resources