Showing posts with label library. Show all posts
Showing posts with label library. Show all posts

Friday, March 23, 2012

hi,Re: Unable to get SQLCMD utility to work properly.

I try to go to a command prompt to get this to run right with no luck. Is there something that I am not doing right? It gives me the help library, but thats about it. Also, I have dealt with Oracle in the past. And was wondering is there a way to access the SQLCMD utility on a workstation with a login of some kind?

--David

hi David,

SqlCMD accepts a list of parameters as described in http://msdn2.microsoft.com/en-us/library/ms165702.aspx and at http://msdn2.microsoft.com/en-us/library/ms170207.aspx you can find a tutorial about it's use...

usually you open a command prompt window and provide the appropriate connection parameters, like

c:\Document and settings\user>sqlcmd -E -S.\SQLExpress

this tries a trusted connection to the local SQLExpress named instance...

if you got it succesfully you get a prompt like
1>

qhere you can just type your Transact-SQL statements..

regards

Monday, March 12, 2012

Here's the answer ... figured it out myself

I'm quite addicted to Patterns-&-Practices Enterprise.Library.Data module, but I can't get it to access a SQL Server Express Database. I've tried several different .CONFIG files and a unch of different settings and I keep getting:

The local database "XXYYZZ" is not defined in configuration.

I'm using Visual Studio 2005 C# in a WinForms application.

Can Microsoft.Practices.EnterpriseLibrary.Data access SQL Server Express Database?

<configuration>

<configSections>

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />

</configSections>

<dataConfiguration defaultDatabase="Connection String" />

<connectionStrings>

<add name="myDb" connectionString="Database=Database;Server=(local)\SQLEXPRESS;AttachDbFilename=C:\myDir\myDBname.mdf;Integrated Security=True;User Instance=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

</configuration>

- and it's use

Database db = DatabaseFactory.CreateDatabase("myDb");
DbCommand dbC = db.GetStoredProcCommand("mySPname");
db.AddInParameter(dbC, "MyParameterName", DbType.Int32, MyIntVal);
DataSet ds = db.ExecuteDataSet(dbC);

Needs this stuff too ...

using System.Data;

using System.Data.SqlTypes;

using System.Data.SqlClient;

using Microsoft.Practices.EnterpriseLibrary.Data;

using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

using System.Data.Common;

|||As the Elib cannot find the "mydb" entry, it seems that the ELIB is requesting the wrong (in terms of your thinking) .config file. See if you are pointing to the right config file.

Jens K. Suessmeyer.

http://www.sqlserver2005.de