Showing posts with label accessing. Show all posts
Showing posts with label accessing. Show all posts

Wednesday, March 21, 2012

Microsoft EnterpriseLibrary connection

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

Drew,

This is because entlib's Database object opens a new connection for you internally if there isn't already one open on the command object. The DbCommand implementation (either SqlCommand, OleDbCommand or OdbcCommand) does not do it for you, hence the error you get on an uninitialized connection.

-- Victor

|||

I guess my question is more of; how do i correct the first snippet?

|||

Not sure which version of EnterpriceLibrary you are using. If you use 2.0 and later, you don't need to create yourself connection. Instead you can use default if you only have one DB connection.

What you need to do is: in your web.config file, add these lines:

<configSections>

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

</configSections>

<dataConfigurationdefaultDatabase="TestDB"/>

<connectionStrings>

<addname="TestDB"connectionString="YourConnectionStringForDBHere;"providerName="System.Data.SqlClient"/>

</connectionStrings>

Please note: <dataConfigurationdefaultDatabase="TestDB"/>

Then, in your code, just do:

Database db =DatabaseFactory.CreateDatabase();

string sqlCommand ="RetrieveCustomer";

DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

db.ExecuteScalar(sqlCommand);

In your case, you can do

string p_ConnectionString = "TestDB";

Hope it helps.

|||

dhysong:

I guess my question is more of; how do i correct the first snippet?

To fix the first snippet you'll have to add code like this:

DbCommand command = db.GetSqlStringCommand("SELECT ...");if (command.Connection.State != ConnectionState.Open){command.Connection.Open();}

-- Victor

Microsoft Drivers for Accessing data from Unix.

Are there any microsoft provided ODBC drivers that can be installed on Unix
side for accessing SQL Server data? OR they are only available from third
party.
Regards,
MZeeshan
MS does not provide an ODBC driver that works on Unix. However, you can
get that from Data Direct. Microsoft does make a JDBC driver though.
MZeeshan wrote:
> Are there any microsoft provided ODBC drivers that can be installed on Unix
> side for accessing SQL Server data? OR they are only available from third
> party.
>
|||Hi MZeeshan,
Thanks for your post.
Unfortunately, I am sorry to say that we do not support ODBC drivers for
UNIX officially. However, I have noticed here is a very good article from
MVP Erland Sommarskog for your reference
Connecting to MS SQL Server from Unix
http://www.sommarskog.se/mssql/unix.html
Hope it helps.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
Business-Critical Phone Support (BCPS) provides you with technical phone
support at no charge during critical LAN outages or "business down"
situations. This benefit is available 24 hours a day, 7 days a week to all
Microsoft technology partners in the United States and Canada.
This and other support options are available here:
BCPS:
https://partner.microsoft.com/US/tec...rview/40010469
Others: https://partner.microsoft.com/US/tec...pportoverview/
If you are outside the United States, please visit our International
Support page: http://support.microsoft.com/common/international.aspx
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.

Microsoft Drivers for Accessing data from Unix.

Are there any microsoft provided ODBC drivers that can be installed on Unix
side for accessing SQL Server data? OR they are only available from third
party.
Regards,
MZeeshanMS does not provide an ODBC driver that works on Unix. However, you can
get that from Data Direct. Microsoft does make a JDBC driver though.
MZeeshan wrote:
> Are there any microsoft provided ODBC drivers that can be installed on Uni
x
> side for accessing SQL Server data? OR they are only available from third
> party.
>|||Hi MZeeshan,
Thanks for your post.
Unfortunately, I am sorry to say that we do not support ODBC drivers for
UNIX officially. However, I have noticed here is a very good article from
MVP Erland Sommarskog for your reference
Connecting to MS SQL Server from Unix
http://www.sommarskog.se/mssql/unix.html
Hope it helps.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
Business-Critical Phone Support (BCPS) provides you with technical phone
support at no charge during critical LAN outages or "business down"
situations. This benefit is available 24 hours a day, 7 days a week to all
Microsoft technology partners in the United States and Canada.
This and other support options are available here:
BCPS:
https://partner.microsoft.com/US/te...erview/40010469
Others: https://partner.microsoft.com/US/te...upportoverview/
If you are outside the United States, please visit our International
Support page: http://support.microsoft.com/common/international.aspx
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

Wednesday, March 7, 2012

Meta Data Services SQL 2000 "msdb database could not be opened"

Hello anyone / everyone,

If you are having trouble accessing Meta Data Services on W2k3 and SQL 2000 and get the error that the "msdb database could not be opened" I found that hot fix 912812 on the operating system is the culprit. Remove it and Meta Data goes back to working, although I am being asked to approve the ActiveX control every time the page refreshes.

Hope this helps somebody, to took me long enough to track it down.

If anyone has a resolution to the ActiveX question I'd love to know the answer.

Thank you,

Uncle Davy


Use "Internet Options" in Internet Explorer and on the security tab, select a "custom level." There you can adjust various properties relating to prompting for and enabling ActiveX controls.

Donald

|||

That would seem the logical choice. However, I tried permitting every activeX and it was still giving me the error!

|||

I have the same error.

SQL 2000 running on Server 2003 SP1.

The hotfix isn't in the list to remove and the permissions have all been granted for activex as well as ensuring database user persmissions are ok.

|||I also removed the "Internet Explorer Enhanced Security Settings" from the server. If you haven't done so try it (Add remove programs -> Add remove windows componenets -> IE enhanced security settings uncheck this).

This was the only issue I ever found (the hotfix) no one ever posted anything about it that was useful.

Of course once I removed the hot fix, I never went back...

Good luck.

Meta Data Services SQL 2000 "msdb database could not be opened"

Hello anyone / everyone,

If you are having trouble accessing Meta Data Services on W2k3 and SQL 2000 and get the error that the "msdb database could not be opened" I found that hot fix 912812 on the operating system is the culprit. Remove it and Meta Data goes back to working, although I am being asked to approve the ActiveX control every time the page refreshes.

Hope this helps somebody, to took me long enough to track it down.

If anyone has a resolution to the ActiveX question I'd love to know the answer.

Thank you,

Uncle Davy


Use "Internet Options" in Internet Explorer and on the security tab, select a "custom level." There you can adjust various properties relating to prompting for and enabling ActiveX controls.

Donald

|||

That would seem the logical choice. However, I tried permitting every activeX and it was still giving me the error!

|||

I have the same error.

SQL 2000 running on Server 2003 SP1.

The hotfix isn't in the list to remove and the permissions have all been granted for activex as well as ensuring database user persmissions are ok.

|||I also removed the "Internet Explorer Enhanced Security Settings" from the server. If you haven't done so try it (Add remove programs -> Add remove windows componenets -> IE enhanced security settings uncheck this).

This was the only issue I ever found (the hotfix) no one ever posted anything about it that was useful.

Of course once I removed the hot fix, I never went back...

Good luck.

Saturday, February 25, 2012

Message says another user accessing data

My Access database as link SQL Server tables. I am trying to remove records
from a subtable and getting this message:
The Microsoft Jet database engine stopped the process becuase you or another
user are attempting to change the same data at the same time.
This isn't the case, however. No one else is on the Database ( I have a
tool which displays the users) and if they were, I am working with test
records which noone would have an interest in viewing.
This happened on a table before, but cleared up when I shut down the
database and opened it again. Now I can't delete the records.
Any help is appreciated.
God Bless,
Mark A. Sam
Mark A. Sam wrote:
> My Access database as link SQL Server tables. I am trying to remove
> records from a subtable and getting this message:
> The Microsoft Jet database engine stopped the process becuase you or
> another user are attempting to change the same data at the same time.
> This isn't the case, however. No one else is on the Database ( I
> have a tool which displays the users) and if they were, I am working
> with test records which noone would have an interest in viewing.
> This happened on a table before, but cleared up when I shut down the
> database and opened it again. Now I can't delete the records.
> Any help is appreciated.
Add a Timestamp column to the table on the server and make sure any bit fields
do not allow Nulls. Links below explain reasons for this to occur.
http://support.microsoft.com/default...kb;en-us;96897
http://support.microsoft.com/default...b;en-us;280730
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
|||Rick,
The table had a time stamp, but a bit filed I just added was allowing nulls.
When I unchecked and tried to save I got this error:
'Customer ST Products Tasks' table
- Unable to modify table.
ADO error: Cannot insert the value NULL into column 'TestRecord', table
'STSIData.dbo.Tmp_Customer ST Products Tasks'; column does not allow nulls.
INSERT fails.
The statement has been terminated.
I don't know what this means since it was checked to allow nulls.
I am working remotely through terminal services and don't have the use of
Project Manager, so I set up a project in Access 2000 to modify the tables.
That could be the problem, I don't know. I tried removing the field and
reentering it, unchecking the 'AllowNulls' checkbox with the same problem.
God Bless,
Mark
"Rick Brandt" <rickbrandt2@.hotmail.com> wrote in message
news:IdJIe.6467$6D5.722@.newssvr29.news.prodigy.net ...
> Mark A. Sam wrote:
> Add a Timestamp column to the table on the server and make sure any bit
fields
> do not allow Nulls. Links below explain reasons for this to occur.
> http://support.microsoft.com/default...kb;en-us;96897
> http://support.microsoft.com/default...b;en-us;280730
> --
> I don't check the Email account attached
> to this message. Send instead to...
> RBrandt at Hunter dot com
>
|||You have to ensure all your bit fields have either a TRUE (1) or FALSE (0)
Value and NO NULL value.
The reason is, several of the records in your table have null values... when
you try to modify the design so that it does not allow nulls, it cant modify
it because there already are nulls in the table in some records.
Try running an update query on that table that converts all NULLS on the
field into 0 "UPDATE tablename set fieldname = 0 where fieldname is null"
then try to modify your table Again
"Mark A. Sam" wrote:

> Rick,
> The table had a time stamp, but a bit filed I just added was allowing nulls.
> When I unchecked and tried to save I got this error:
> 'Customer ST Products Tasks' table
> - Unable to modify table.
> ADO error: Cannot insert the value NULL into column 'TestRecord', table
> 'STSIData.dbo.Tmp_Customer ST Products Tasks'; column does not allow nulls.
> INSERT fails.
> The statement has been terminated.
>
> I don't know what this means since it was checked to allow nulls.
> I am working remotely through terminal services and don't have the use of
> Project Manager, so I set up a project in Access 2000 to modify the tables.
> That could be the problem, I don't know. I tried removing the field and
> reentering it, unchecking the 'AllowNulls' checkbox with the same problem.
> God Bless,
> Mark
>
> "Rick Brandt" <rickbrandt2@.hotmail.com> wrote in message
> news:IdJIe.6467$6D5.722@.newssvr29.news.prodigy.net ...
> fields
>
>
|||There aren't any Null values. In fact I am able to delete new records, but
there is a batch that I am unable to remove. When I added the Field, the
system entered 0 to the existing records.
"TNB" <TNB@.discussions.microsoft.com> wrote in message
news:509E4A52-DE3B-4B03-9996-2DA7698B7DCB@.microsoft.com...
> You have to ensure all your bit fields have either a TRUE (1) or FALSE (0)
> Value and NO NULL value.
> The reason is, several of the records in your table have null values...
when
> you try to modify the design so that it does not allow nulls, it cant
modify[vbcol=seagreen]
> it because there already are nulls in the table in some records.
> Try running an update query on that table that converts all NULLS on the
> field into 0 "UPDATE tablename set fieldname = 0 where fieldname is null"
> then try to modify your table Again
> "Mark A. Sam" wrote:
nulls.[vbcol=seagreen]
nulls.[vbcol=seagreen]
of[vbcol=seagreen]
tables.[vbcol=seagreen]
problem.[vbcol=seagreen]
time.[vbcol=seagreen]
bit[vbcol=seagreen]
|||Well this clear up for no apparent reason other than prayer. ;)
"TNB" <TNB@.discussions.microsoft.com> wrote in message
news:509E4A52-DE3B-4B03-9996-2DA7698B7DCB@.microsoft.com...
> You have to ensure all your bit fields have either a TRUE (1) or FALSE (0)
> Value and NO NULL value.
> The reason is, several of the records in your table have null values...
when
> you try to modify the design so that it does not allow nulls, it cant
modify[vbcol=seagreen]
> it because there already are nulls in the table in some records.
> Try running an update query on that table that converts all NULLS on the
> field into 0 "UPDATE tablename set fieldname = 0 where fieldname is null"
> then try to modify your table Again
> "Mark A. Sam" wrote:
nulls.[vbcol=seagreen]
nulls.[vbcol=seagreen]
of[vbcol=seagreen]
tables.[vbcol=seagreen]
problem.[vbcol=seagreen]
time.[vbcol=seagreen]
bit[vbcol=seagreen]

Message says another user accessing data

My Access database as link SQL Server tables. I am trying to remove records
from a subtable and getting this message:
The Microsoft Jet database engine stopped the process becuase you or another
user are attempting to change the same data at the same time.
This isn't the case, however. No one else is on the Database ( I have a
tool which displays the users) and if they were, I am working with test
records which noone would have an interest in viewing.
This happened on a table before, but cleared up when I shut down the
database and opened it again. Now I can't delete the records.
Any help is appreciated.
God Bless,
Mark A. SamMark A. Sam wrote:
> My Access database as link SQL Server tables. I am trying to remove
> records from a subtable and getting this message:
> The Microsoft Jet database engine stopped the process becuase you or
> another user are attempting to change the same data at the same time.
> This isn't the case, however. No one else is on the Database ( I
> have a tool which displays the users) and if they were, I am working
> with test records which noone would have an interest in viewing.
> This happened on a table before, but cleared up when I shut down the
> database and opened it again. Now I can't delete the records.
> Any help is appreciated.
Add a Timestamp column to the table on the server and make sure any bit fiel
ds
do not allow Nulls. Links below explain reasons for this to occur.
http://support.microsoft.com/defaul...=kb;en-us;96897
http://support.microsoft.com/defaul...kb;en-us;280730
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com|||Rick,
The table had a time stamp, but a bit filed I just added was allowing nulls.
When I unchecked and tried to save I got this error:
'Customer ST Products Tasks' table
- Unable to modify table.
ADO error: Cannot insert the value NULL into column 'TestRecord', table
'STSIData.dbo.Tmp_Customer ST Products Tasks'; column does not allow nulls.
INSERT fails.
The statement has been terminated.
I don't know what this means since it was checked to allow nulls.
I am working remotely through terminal services and don't have the use of
Project Manager, so I set up a project in Access 2000 to modify the tables.
That could be the problem, I don't know. I tried removing the field and
reentering it, unchecking the 'AllowNulls' checkbox with the same problem.
God Bless,
Mark
"Rick Brandt" <rickbrandt2@.hotmail.com> wrote in message
news:IdJIe.6467$6D5.722@.newssvr29.news.prodigy.net...
> Mark A. Sam wrote:
> Add a Timestamp column to the table on the server and make sure any bit
fields
> do not allow Nulls. Links below explain reasons for this to occur.
> http://support.microsoft.com/defaul...=kb;en-us;96897
> http://support.microsoft.com/defaul...kb;en-us;280730
> --
> I don't check the Email account attached
> to this message. Send instead to...
> RBrandt at Hunter dot com
>|||You have to ensure all your bit fields have either a TRUE (1) or FALSE (0)
Value and NO NULL value.
The reason is, several of the records in your table have null values... when
you try to modify the design so that it does not allow nulls, it cant modify
it because there already are nulls in the table in some records.
Try running an update query on that table that converts all NULLS on the
field into 0 "UPDATE tablename set fieldname = 0 where fieldname is null"
then try to modify your table Again
"Mark A. Sam" wrote:

> Rick,
> The table had a time stamp, but a bit filed I just added was allowing null
s.
> When I unchecked and tried to save I got this error:
> 'Customer ST Products Tasks' table
> - Unable to modify table.
> ADO error: Cannot insert the value NULL into column 'TestRecord', table
> 'STSIData.dbo.Tmp_Customer ST Products Tasks'; column does not allow nulls
.
> INSERT fails.
> The statement has been terminated.
>
> I don't know what this means since it was checked to allow nulls.
> I am working remotely through terminal services and don't have the use of
> Project Manager, so I set up a project in Access 2000 to modify the tables
.
> That could be the problem, I don't know. I tried removing the field and
> reentering it, unchecking the 'AllowNulls' checkbox with the same problem.
> God Bless,
> Mark
>
> "Rick Brandt" <rickbrandt2@.hotmail.com> wrote in message
> news:IdJIe.6467$6D5.722@.newssvr29.news.prodigy.net...
> fields
>
>|||There aren't any Null values. In fact I am able to delete new records, but
there is a batch that I am unable to remove. When I added the Field, the
system entered 0 to the existing records.
"TNB" <TNB@.discussions.microsoft.com> wrote in message
news:509E4A52-DE3B-4B03-9996-2DA7698B7DCB@.microsoft.com...
> You have to ensure all your bit fields have either a TRUE (1) or FALSE (0)
> Value and NO NULL value.
> The reason is, several of the records in your table have null values...
when
> you try to modify the design so that it does not allow nulls, it cant
modify[vbcol=seagreen]
> it because there already are nulls in the table in some records.
> Try running an update query on that table that converts all NULLS on the
> field into 0 "UPDATE tablename set fieldname = 0 where fieldname is null"
> then try to modify your table Again
> "Mark A. Sam" wrote:
>
nulls.[vbcol=seagreen]
nulls.[vbcol=seagreen]
of[vbcol=seagreen]
tables.[vbcol=seagreen]
problem.[vbcol=seagreen]
time.[vbcol=seagreen]
bit[vbcol=seagreen]|||Well this clear up for no apparent reason other than prayer. ;)
"TNB" <TNB@.discussions.microsoft.com> wrote in message
news:509E4A52-DE3B-4B03-9996-2DA7698B7DCB@.microsoft.com...
> You have to ensure all your bit fields have either a TRUE (1) or FALSE (0)
> Value and NO NULL value.
> The reason is, several of the records in your table have null values...
when
> you try to modify the design so that it does not allow nulls, it cant
modify[vbcol=seagreen]
> it because there already are nulls in the table in some records.
> Try running an update query on that table that converts all NULLS on the
> field into 0 "UPDATE tablename set fieldname = 0 where fieldname is null"
> then try to modify your table Again
> "Mark A. Sam" wrote:
>
nulls.[vbcol=seagreen]
nulls.[vbcol=seagreen]
of[vbcol=seagreen]
tables.[vbcol=seagreen]
problem.[vbcol=seagreen]
time.[vbcol=seagreen]
bit[vbcol=seagreen]