Microsoft EnterpriseLibrary 'connection
Jul 19, 2007
I hope this is the right place to ask this:
I am using the microsoft enterpriselibrary for accessing a sql server database. when I use the following code, I receive an error 'ExecuteScalar: Connection property has not been initialized.':
---------------------------------------------------------------------------
Database db = new SqlDatabase(p_ConnectionString);
DbCommand cmd = db.GetSqlStringCommand(p_Sql);
output = cmd.ExecuteScalar();
----------------------------------------------------------------------------
but when I use this code, everything works correctly:
---------------------------------------------------------------------------
Database db = new SqlDatabase(p_ConnectionString);
DbCommand cmd = db.GetSqlStringCommand(p_Sql);
output = db.ExecuteScalar(cmd);
----------------------------------------------------------------------------
I was assured by my supervisor that both snippets' syntax are correct. Can anyone shine some light on why the first snippet will throw an exception?
Thanks in advance,
Drew
View 4 Replies
ADVERTISEMENT
May 12, 2006
So I got 2 classes one I wrote to interrogate databases using normal ADO:Mine:SqlConnection myConnection = new SqlConnection(m_sConnectionString);SqlCommand myCommand = new SqlCommand(sQuery, myConnection);myCommand.CommandTimeout = 120; // 60 Seconds TimeoutmyConnection.Open();SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);return result;Microsoft WaySqlDatabase dbSvc = new SqlDatabase(m_sConnectionString);DbCommand dbCommand = dbSvc.GetSqlStringCommand(sQuery);return ((SqlDataReader)dbSvc.ExecuteReader(dbCommand));What's faster?My way:SqlConnection myConnection = new SqlConnection(m_sConnectionString);SqlCommand myCommand = new SqlCommand(sQuery, myConnection);myCommand.CommandTimeout = 120; // 60 Seconds Timeout// Use a DataTable – required for default pagingSqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);DataTable myTable = new DataTable();myAdapter.Fill(myTable);myConnection.Close();myConnection.Dispose();myConnection = null;return (myTable);Microsoft Way:SqlDatabase dbSvc = new SqlDatabase(m_sConnectionString);DbCommand dbCommand = dbSvc.GetSqlStringCommand(sQuery);DataTable dtData = null;DataSet dsData = dbSvc.ExecuteDataSet(dbCommand);dtData = dsData.Tables[0];return (dtData);Comments? Ideas?Al
View 4 Replies
View Related
Aug 2, 2006
Hello
I created a wrapper class for a function, and exposed it through CLR. However, if I call this function form SQL it blows up but if I call directly from a test Windows Form the call works fine.
The blow up is related to EnterpriseLibrary.Data, where my Queue class uses that library to do all data access call ops
Here's my wrapper class:
namespace inlineCLRsql{
public static class Wrapper{
public static void CallQueueEntry(int queueId, int deskNo, int missed){
inLineLib.Queue oQueue;
inLineLib.QueueEntry oQueueEntry;
oQueue = new inLineLib.Queue(queueId);
oQueueEntry = oQueue.callQueueEntry(deskNo, false);
Microsoft.SqlServer.Server.SqlContext.Pipe.Send(oQueueEntry.queueNum.ToString());
}
}
And this is my CLR SQL creation code:
CREATE PROC sp_CallQueueEntry
@queueId int,
@deskNo int,
@missed int
AS
EXTERNAL NAME inLineLib.[inlineCLRsql.Wrapper].CallQueueEntry
GO
sp_CallQueueEntry 4,2,0
Here is what I get as a result
System.NullReferenceException: Object reference not set to an instance of an object.
System.NullReferenceException:
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.get_DefaultName()
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseMapper.MapName(String name, IConfigurationSource configSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp[TTypeToBuild](IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault()
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase()
at inLineLib.Queue.getNextQueueEntry(Int32 servedBy)
at inLineLib.Queue.callQueueEntry(Int32 servedBy, Boolean callMissed)
at inlineCLRsql.Wrapper.CallQueueEntry(Int32 queueId, Int32 deskNo, Int32 missed)
What can I do to fix this?
Cheers
M
View 1 Replies
View Related
Sep 27, 2007
in the class library i written the code name :customer is the lib name
using System;
using System.Collections.Generic;
using System.Text;
namespace Customer
{ class Entites
{
public int inTest;
public int inTest2;
}
}
Now in the Class1.cs i written the code
i am getting the data from the database by using enterprise lib 2006 connection function
now HOW TO BIND THE DATA TO LIST AND RETURN TYPE IS LIST
PLEASE CHECK THE CODE AND REDEFINE THE CODE
using System;
using System.Data ;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using System.Collections;
using System.Xml.Serialization;
using System.Data.Common;
using Customer;
namespace Customer
{
class Class1
{
public List<Entites> getdata(int id)
{
Database db = DatabaseFactory.CreateDatabase("mycon");
System.Data.Common.DbCommand cmd ;
cmd = db.GetStoredProcCommand("GET_CUSTOMER");
cmd.CommandType = CommandType.StoredProcedure;
db.AddInParameter(cmd,"@CID",System.Data.DbType.Int32,id);
List<Entites> objEntites = new List<Entites>();
using (IDataReader dr = db.ExecuteReader(cmd))
foreach (Entites obj in dr)
{
objEntites.inTest = obj.inTest;-----------------------------------------------ERROR LINE
// objEntites.Add(obj);
}
return objEntites;
}
}
}
Error 2 foreach statement cannot operate on variables of type 'System.Data.IDataReader' because 'System.Data.IDataReader' does not contain a public definition for 'GetEnumerator' D:KOTI_PRJSEnterpriseCustomerClass1.cs 34 13 Customer
View 1 Replies
View Related
Oct 11, 2006
Hi
I am having diffuculty with multi owner stored procs with enterprise library deriveparameters.
Eg:
Create proc dbo.test @p1 int as select 'hi'
create proc bob.test @p1 int as select 'hi'
Deriveparameters appears to tell us the wrong number of parameters. I gather it is getting ALL the parameters for all procs called 'test' regardless of the owner.
If anyone can give me some guidance on this I would appreciate it!
Rich
View 2 Replies
View Related
Feb 2, 2007
OK, heres the situation:
I am using Visual Web Developer 2005 Express Edition along with SQL Server 2005 Express Edition on the same computer. ALL I WANT TO DO IS MAKE A SIMPLE CONNECTION TO THE DB. I have tried using every possible type of connection string that I can find on the internet (of which there seems to be WAY too many), but none of them seem to work. I can't believe how difficult this is. Any ideas? I am using windows authentication, and the management server utility connects fine. So this is really annoying. PLEASE HELP
View 1 Replies
View Related
Jul 27, 2006
<connectionStrings>
<add name="AppConnectionString1" connectionString="Data Source=".SQLEXPRESS";AttachDbFilename="C:Program FilesMicrosoft SQL ServerMSSQLDataAdventureWorks2000_Data.mdf";Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
I'm running Microsoft SQL server 2005. what is the error in the above code.
View 2 Replies
View Related
Jun 8, 1999
Hello,
I am trying to connect to a Microsoft SQL Server 7.0 from a SCO box (version 3.2v4.2)using sisql/bcp (sybase product). I can connect to a 6.5 database but when I try the same script to connect to 7.0 I get the following message: DB-LIBRARY error:
Unable to connect: SQL Server is unavailable or does not exist.
Is there anything I can do in order to fix this problem? Any ideas?
Thanks
View 1 Replies
View Related
Jun 19, 2008
Hi, I am using Microsoft Visual Web Developer 2008 Express Edition. I wanted to add a database to the Project. When i add it, it says "An error occured while extablishing an connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQl Server does not allow remote connections. (provider: SQL Network Interfaces, error:26- Error locating server / instance specified). Please let me know what is the cause of this error. Initially i downloaded Microsoft Adventure works database and saved the file as .mdf and tried to access it through the data grid. I got the same error message as above. I changed the settings in SQl server to enable remote access and also changed firewall settings to allow SQL server exe files. Then i uninstalled works db and now have disabled remote access and still have the firewall settings to allow SQL server on. Thanks,Vidhya
View 2 Replies
View Related
Mar 15, 2004
i installed the MSDE2000A on server and i tried to connect from client machine through vb Application using connection string. Server anad client are in LAN. but Some systems able to connect and some systems are unable to connect.
i am getting the error:
"SqlServer does not exist or access denied "
for non connected machines.
the server is listening from these machines. but not connecting to MSDE.
can anyone give me solution what may be the cause.
View 6 Replies
View Related
Apr 21, 2008
Hi!
I've a computer with W2K SP4 installed. Previously SQL Express 2005 worked but according to the user it "just stopped working".
When selecting database on the server in the "Data Link Properties"-window he is given the following error message:
"Microsoft Data Link" "Login failed. Catalog information cannot be retrieved"
followed by
"Microsoft Data Link Error" "Connection failure"
Note: He is not given the error message "Server does not exist or access denied!"
- The SQL service is started (can be stopped and restarted without problem)
- I've re-installed SQL Express.
- I've checked and is certain the server name is correct (i.e. computernameSQLEXPRESS)
Any ideas here because I'm getting desperate?
Thanks in advance,
Peter Hartlén
View 7 Replies
View Related
May 21, 2007
I am trying to connect to SQL Server 2005 Express with JDBC. I am getting the following exception:
Code SnippetString connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=IFC3;";
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl,"ifc2","password");
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at connectURL.main(connectURL.java:43)
I am using the code example that came from Microsoft for making a JDBC connection. I looked at my configuration of SQL Server and change to use a static port 1433. I shut off Windows firewall to make sure it was not blocking communication.
When I try to telnet to port 1433 it says
Connecting To 1433...Could not open connection to the host, on port 23: Connect
failed
Any suggestions?
Thanks,
Tom
View 14 Replies
View Related
Aug 3, 2006
Hi All,
I have downloaded Microsoft Enterprise Library 2005 from microsoft.com. I am trying implement Data Access Layer with visual studio 2003. I am able to access some functions of the DAL but I am not able to establish connection with SQL Server 2000.
Will anyone tell me the solution for the above issue.
Thanks & Regards,
Bijay
View 4 Replies
View Related
May 10, 2007
Our program report the error like this:
[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt.
I used VC++ and ADO.
How does this error happen?
How can I fix it?
Does this can be caused by mutil-thread?
We use the SqlServer 2005.
Thanks
View 4 Replies
View Related
May 9, 2007
Our program report the error like this:
[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt.
How does this error happen?
How can I fix it?
We use the SqlServer 2005.
Thanks
View 6 Replies
View Related
Sep 17, 2015
I am trying to create a Datazen query against a Microsoft SharePoint List. The Data View successfully returns records from the list; however, it appears that the Query String parameter is entirely ignored. I want to use the query string to grab only records with a certain status value.
So far I have attempted specifying a View and Filters:
?View={B9FF1729-AB8E-4C55-B17C-C660480334BB}&FilterField1=Status&FilterValue1=Closed&FilterField2=Request%5Fx0020%5FType&FilterValue2=Project
Just the filters:
?FilterField1=Status&FilterValue1=Closed&FilterField2=Request%5Fx0020%5FType&FilterValue2=Project
And even:
?ThisWillDoNothing
All return the complete set of records in the list. I do not see a single example or comment online other than the claim that SharePoint List sources are supported. How I can specify a Query String value that will filter the list records?
View 2 Replies
View Related
Apr 10, 2007
Hi
i connect to remote Integration Service. i configure server for remote connection( on component services and DCOM config , ... ) .and now i can connect to Integration Service remotely and correctly.
but when i expand Stored Package and then click to expand MSDB this error will hapen:
login failed for user ... .(microsoft sql native client )
please help me
thanks in advance
View 1 Replies
View Related
Mar 28, 2007
Hi!
I have developed a database in MS SQL Server 2005 Express, to which I would require only bulkadmin server role from an external java application, because I only need to update rows, insert values or use select queries in the database.
The problem is that, using either the Microsoft JDBC Driver 1.1 or the Java JDBC ODBC Driver and the Windows XP Data Base (ODBC) configurations, I need a user with sysadmin server role inside Sql Server, otherwise JDBC won't connect to the database using the selected user. Even if I leave the sql login with setupadmin or any server role lower than sysadmin, the connection is refused.
Is there no way to connect using JDBC to MS Sql Server 2005 other than granting the connected user sysadmin rights? My code looks as follows:
Code Snippet
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url = "jdbc:sqlserver://FIREBLADE\SQLEXPRESS";
String user = "username";
String password = "password$$";
Connection conn;
Class.forName(driver);
conn = DriverManager.getConnection(url,user,password);
if (conn != null)
System.out.println("SQL Server Connection established ...");
I have heard that Java JDBC connections to Microsoft require high-level access.
Any informed answer is more than welcome. Thanks for reading my post!
View 1 Replies
View Related
Oct 26, 2007
How to use Microsoft Data Link(Udl) type file to connect with SQL Server using SQL Native Client,If i use OLDEDB Connection i can make connection using UDL file with Database ,but how can i use a file for a connection using SQL Native Client.Is there any other data link file that can be used to connect with SQL server using SQL Native Client.
View 5 Replies
View Related
Feb 22, 2006
Hello,
On my dev server I have working ssis packages that use connections Microsoft OLEDB provider for Oracle MSDAORA.1 and Oracle provider for oledb and OracleClient data provider.
I use one or the other according to my needs.
In anticipation and to prepare for the build of a new production server, I have build a test server from scratch and deployed to it the entire dev.
Almost everything works except Microsoft OLEDB provider for Oracle.
ssis packages on the test machine will return an error
Error at Pull Calendar from One [OLE DB Source [1]]: The AcquireConnection method call to the connection manager "one.oledb" failed with error code 0xC0202009.
Error at Pull Calendar from One [DTS.Pipeline]: component "OLE DB Source" (1) failed validation and returned error code 0xC020801C.
[Connection manager "one.oledb"]: An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80004005 Description: "Oracle error occurred, but error message could not be retrieved from Oracle.".
I have used the same installers for OS, SQL and Oracle SQL*Net on both dev and test machines. The install and then the restore/deployment on Test went fine.
Does anyone could point me to the right direction to solve this issue?
Thanks,
Philippe
View 17 Replies
View Related
May 2, 2006
On Windows XP systems I get the following issue when trying to browse the MSDB folder in SSIS
Client unable to establish connection
Encryption not supported on SQL Server. (Microsoft SQL Native Client)
I have noticed another post where several others have noticed the same issue. It appears to only occur on Windows XP installations. Is there a workaround or fix for this?
View 2 Replies
View Related
Jan 10, 2007
I am getting the above error when I try to create Notificatioin services new Instance.
Additional Information is
Failed to connect to server ABC(Microsoft.SqlServer.ConnectionInfo)
An error occured while establishing connection to the server.When connecting to SQL Server 2005, this failure may be caused by the fact that under default settings SQL Server deoes not allow remote connections.(Provider : Named Pipes Provider, error 40 -could not open connection to SQL Server)(Microsoft SQL Server error: 53)
Please help me I am new to SQL Server 2005.I can't able to proceed.
View 6 Replies
View Related
Jul 25, 2007
Hello, How are you?
I have a problem when I try to create a new connection with Microsoft SQL Server 2005 Compact Edition from Visual Studio 2005 IDE. When I€™m going to choose the data source, the SQL Server 2005 Compact Edition provider doesn€™t appear in the list. I installed the SQL Server 2005 Compact Edition from this page http://www.microsoft.com/downloads/details.aspx?FamilyId=%2085E0C3CE-3FA1-453A-8CE9-AF6CA20946C3&displaylang=en. In the additional information says by installing SQLServerCE31-EN.msi installs the provider (System.Data.SqlServerCe.dll) in the GAC (global assembly cache) and registers the OLEDB provider (sqlceoledb30.dll). So, I don€™t understand why couldn€™t I create a new connection with Microsoft SQL Server 2005 Compact Edition from Visual Studio 2005 IDE?
I appreciate your help€¦
View 6 Replies
View Related
Jun 21, 2007
Hi
I am trying to use Association Viewer Control in
Microsoft.AnalysisServices.Viewers.DLL dll in VS 2005 but sometimes it gives an error.
"Code generatio for property 'ConnecitonManager'" failed. Error was:'Property accesor 'ConnectionManager' on object 'AssosiactionViewer1' threw the following exception:'Object referance not set to instance of an object"
Is there anyone here who use
"Microsoft SQL Server 2005 Datamining Viewer Controls" in SQLServer2005 FeaturePack ?
http://www.microsoft.com/downloads/details.aspx?FamilyID=50b97994-8453-4998-8226-fa42ec403d17&DisplayLang=en
i am using VS2005 Version 8.0.50727.762 (SP.050727-7600)
and SQL Server 2005 SP2
thanks from now.
Cem Ãœney
View 9 Replies
View Related
Jul 23, 2005
Dear All,Access adp on sql-server 2000After upgrating to A2003 updating data with 1 perticular combobox causes theprogram to hangs without any error-msg.Traying to change te combobox recordsource i get this error:This version of Microsoft Access doesn't support design changes to theversion of Microsoft SQL Server your project is connected to. See theMicrosoft Office Update Web site for the latest information and downloads(on the Help menu, click Office on the Web). Your design changes will not besaved.The solution in :http://support.microsoft.com/defaul...kb;en-us;313298tolks about SP 'dt_verstamp007' but I have SP 'dt_verstamp006'What should I do.Is the failure of the combobox also caused by the absence of dt_verstamp007???Filip
View 2 Replies
View Related
May 22, 2007
odbc_pconnect() [function.odbc-pconnect]: SQL error: [Microsoft][ODBC Microsoft Access Driver] System resource exceeded., SQL state S1001 in SQLConnect
we got the error with access 2000 database and PHP as prog. language .
we created dsn for the connection.
reboot solves the problem. but we need another solution better than this.
View 7 Replies
View Related
Sep 25, 2007
Hi,
I'm trying to install Microsoft Dynamics 10.0 with SQL 2008 Dev but when launching the utilities this returns the following error message:
******************************************************************
Your current SQL Server is not a supported version.
Req: Microsoft SQL Server 8.0
Act: Microsoft SQL Server code name "Katmai" (CTP) - 10
You need to upgrade to SQL Server 8.0 before continuing.
******************************************************************
Any ideas could help or has this if anyone knows been desinged not to work with GP10 currently?
Assad
View 7 Replies
View Related
Mar 17, 2008
I have a query that executes just fine except that it won't recognize varchar(255) ( or any other value within the () ) and if I leave it off like this: varchar, then it executes but it leaves that value as 1 and that is just not very useful for my purposes. This also happens with anything else that requires () to add length such as char(), or nvarchar(), etc... Any ideas?
View 1 Replies
View Related
Aug 21, 2007
Login Failed for user , the user is not associated with a trusted sql server connection. (microsoft SQL Server,Error:18452)
hi ,
i am getting the above error message once in a while maybe two or 3 times a week , and then it goes away in 10 to 15 minutes or 5 minutes ,
our mode is set to mixed and we are able to connect and use both sql and windows , but once in a while , it will give us the above message when we try connecting throught sql server management studio client (using sql 05) using windows login , although it lets us connect using sql login while the windows login is denied, and after a while it lets us connect with both.
occurs randomly on some days , we run our servers on VM ware virtual machines using windows 2003 r2 enterprise 64 bit with sp2 with esx 301 virtual machine.
would appericate any feedback on this thanks
View 5 Replies
View Related
Dec 12, 2007
Can anyone give a quick description of the meaning of this message andwhat needs to be done to get a connection.I'm running DBArtisan with SQLServer 2000 client SP4 installed.I also get the same message with MS Enterprise Manager so this iscoming out of the actual ODBC connection attempt.Thanks in advance!
View 1 Replies
View Related
Aug 26, 2006
hello all member
View 14 Replies
View Related
Jul 23, 2005
I'm not asking a lot. I just want to know if I can connect from anExchange server to a SQl server without having to use Access linkedtables. Surely MS must have had a look at this but I can't findanything out there.Help appreciated.Ginters
View 1 Replies
View Related
Oct 3, 2001
Hello,
"Failed to copy objects from Microsoft SQL Server to Microsoft SQL Server "
I keep getting this when trying to copy stored procs from one db to another on the same server. I am using the DTS wizard. I have been able to copy the tables but I need the sp's too, and there are too many to copy one at a time.
Help!
TIA,
Bruce
View 1 Replies
View Related