Showing posts with label application. Show all posts
Showing posts with label application. Show all posts

Friday, March 30, 2012

One instance or two instances

Hi,

If I have two applications which have several databases for each application, do you create one instance for two applications or you create one instance for each application? Which way is better on pricing, performance, maintanence etc?

Thanks for your input

It does not matter as far as pricing goes. You can install multiple instances on the same server once you have a single license.

If you have multiple instances on the same server, you need to think about how much memory you allocate to each instance (by setting the max memory option). In most cases you would be better off (especially from a performance and maint perspective) to only have one instance on the machine, rather than one instance per application.

Multiple instances can be more secure (from each other), and they can be at different SP levels.

|||

thanks for your help.

Where I can change the parameter for the instance on memory limitation etc?

Thanks

|||

In SQL Server 2005, you can use SQL Server Management Studio (SSMS). In Object Explorer, select the instance, right-click and select Properties. Then select Memory, and set the value for the Max server memory. You want to leave some memory for the OS.

Please mark this question as answered if this was helpful. Thanks!

Wednesday, March 28, 2012

One database or many database?

I have a web application which collect data from MANY clients. Data
collected is in the same structure, my questions is: to use one database
store all data or create a database for each client? which way is better?
Thank you
Quinn
There is no right or wrong answer here. If you have one huge DB, then
backup and recovery can be problematic. If you have 100's of small DB's,
then it becomes an administrative challenge, though much admin can be
automated/scripted.
There are also security issues. Some clients refuse to commingle their data
with other companies.
Also, if you needed to separate a client into its own DB on another server,
it's not straightforward. Whereas, if you have each client in it's own DB,
it's just a matter of backup and restore.
If the number of clients that you have is small, then likely you can get
away with a single DB.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Quinn" <qjia@.yahoo.com> wrote in message
news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
I have a web application which collect data from MANY clients. Data
collected is in the same structure, my questions is: to use one database
store all data or create a database for each client? which way is better?
Thank you
Quinn
|||Thank you Tom.
Right now I don't know how many clients yet, but 500+- may close enough.
Quinn
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23G8mcPspHHA.4212@.TK2MSFTNGP04.phx.gbl...
> There is no right or wrong answer here. If you have one huge DB, then
> backup and recovery can be problematic. If you have 100's of small DB's,
> then it becomes an administrative challenge, though much admin can be
> automated/scripted.
> There are also security issues. Some clients refuse to commingle their
> data
> with other companies.
> Also, if you needed to separate a client into its own DB on another
> server,
> it's not straightforward. Whereas, if you have each client in it's own
> DB,
> it's just a matter of backup and restore.
> If the number of clients that you have is small, then likely you can get
> away with a single DB.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Quinn" <qjia@.yahoo.com> wrote in message
> news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
> I have a web application which collect data from MANY clients. Data
> collected is in the same structure, my questions is: to use one database
> store all data or create a database for each client? which way is better?
>
> Thank you
> Quinn
>
|||Then, if you go the one DB per client route, you'll need to automate your
maintenance processes, e.g. backup, reindexing and the like. It's not that
big of a problem; you just need to have it in place.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Quinn" <qjia@.yahoo.com> wrote in message
news:OceHgUspHHA.4772@.TK2MSFTNGP05.phx.gbl...
Thank you Tom.
Right now I don't know how many clients yet, but 500+- may close enough.
Quinn
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23G8mcPspHHA.4212@.TK2MSFTNGP04.phx.gbl...
> There is no right or wrong answer here. If you have one huge DB, then
> backup and recovery can be problematic. If you have 100's of small DB's,
> then it becomes an administrative challenge, though much admin can be
> automated/scripted.
> There are also security issues. Some clients refuse to commingle their
> data
> with other companies.
> Also, if you needed to separate a client into its own DB on another
> server,
> it's not straightforward. Whereas, if you have each client in it's own
> DB,
> it's just a matter of backup and restore.
> If the number of clients that you have is small, then likely you can get
> away with a single DB.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Quinn" <qjia@.yahoo.com> wrote in message
> news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
> I have a web application which collect data from MANY clients. Data
> collected is in the same structure, my questions is: to use one database
> store all data or create a database for each client? which way is better?
>
> Thank you
> Quinn
>
|||"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:uRUj1fspHHA.2156@.TK2MSFTNGP03.phx.gbl...
> Then, if you go the one DB per client route, you'll need to automate your
> maintenance processes, e.g. backup, reindexing and the like. It's not
> that
> big of a problem; you just need to have it in place.
I'm doing this for 400+ databases in two systems, and the maintenance stuff
is a one-time cost. The ability to move a resource-hoggy client to its own
instance or server is well worth the time invested up front to support them
all.
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
|||That's a major advantage - the ability to parse off a large client onto
another server as required. Taking it to the next level, let's say you have
those 400+ DB's on 4 servers. You can then move DB's from one box to
another to level the load. Sur, it's manual, but if you take regular
performance stats, you are then in a good position to figure out who goes
where.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:OvZbmStpHHA.3512@.TK2MSFTNGP06.phx.gbl...
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:uRUj1fspHHA.2156@.TK2MSFTNGP03.phx.gbl...
> Then, if you go the one DB per client route, you'll need to automate your
> maintenance processes, e.g. backup, reindexing and the like. It's not
> that
> big of a problem; you just need to have it in place.
I'm doing this for 400+ databases in two systems, and the maintenance stuff
is a one-time cost. The ability to move a resource-hoggy client to its own
instance or server is well worth the time invested up front to support them
all.
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006

One database or many database?

I have a web application which collect data from MANY clients. Data
collected is in the same structure, my questions is: to use one database
store all data or create a database for each client? which way is better?
Thank you
QuinnThere is no right or wrong answer here. If you have one huge DB, then
backup and recovery can be problematic. If you have 100's of small DB's,
then it becomes an administrative challenge, though much admin can be
automated/scripted.
There are also security issues. Some clients refuse to commingle their data
with other companies.
Also, if you needed to separate a client into its own DB on another server,
it's not straightforward. Whereas, if you have each client in it's own DB,
it's just a matter of backup and restore.
If the number of clients that you have is small, then likely you can get
away with a single DB.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Quinn" <qjia@.yahoo.com> wrote in message
news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
I have a web application which collect data from MANY clients. Data
collected is in the same structure, my questions is: to use one database
store all data or create a database for each client? which way is better?
Thank you
Quinn|||Thank you Tom.
Right now I don't know how many clients yet, but 500+- may close enough.
Quinn
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23G8mcPspHHA.4212@.TK2MSFTNGP04.phx.gbl...
> There is no right or wrong answer here. If you have one huge DB, then
> backup and recovery can be problematic. If you have 100's of small DB's,
> then it becomes an administrative challenge, though much admin can be
> automated/scripted.
> There are also security issues. Some clients refuse to commingle their
> data
> with other companies.
> Also, if you needed to separate a client into its own DB on another
> server,
> it's not straightforward. Whereas, if you have each client in it's own
> DB,
> it's just a matter of backup and restore.
> If the number of clients that you have is small, then likely you can get
> away with a single DB.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Quinn" <qjia@.yahoo.com> wrote in message
> news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
> I have a web application which collect data from MANY clients. Data
> collected is in the same structure, my questions is: to use one database
> store all data or create a database for each client? which way is better?
>
> Thank you
> Quinn
>|||Then, if you go the one DB per client route, you'll need to automate your
maintenance processes, e.g. backup, reindexing and the like. It's not that
big of a problem; you just need to have it in place.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Quinn" <qjia@.yahoo.com> wrote in message
news:OceHgUspHHA.4772@.TK2MSFTNGP05.phx.gbl...
Thank you Tom.
Right now I don't know how many clients yet, but 500+- may close enough.
Quinn
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23G8mcPspHHA.4212@.TK2MSFTNGP04.phx.gbl...
> There is no right or wrong answer here. If you have one huge DB, then
> backup and recovery can be problematic. If you have 100's of small DB's,
> then it becomes an administrative challenge, though much admin can be
> automated/scripted.
> There are also security issues. Some clients refuse to commingle their
> data
> with other companies.
> Also, if you needed to separate a client into its own DB on another
> server,
> it's not straightforward. Whereas, if you have each client in it's own
> DB,
> it's just a matter of backup and restore.
> If the number of clients that you have is small, then likely you can get
> away with a single DB.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Quinn" <qjia@.yahoo.com> wrote in message
> news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
> I have a web application which collect data from MANY clients. Data
> collected is in the same structure, my questions is: to use one database
> store all data or create a database for each client? which way is better?
>
> Thank you
> Quinn
>|||"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:uRUj1fspHHA.2156@.TK2MSFTNGP03.phx.gbl...
> Then, if you go the one DB per client route, you'll need to automate your
> maintenance processes, e.g. backup, reindexing and the like. It's not
> that
> big of a problem; you just need to have it in place.
I'm doing this for 400+ databases in two systems, and the maintenance stuff
is a one-time cost. The ability to move a resource-hoggy client to its own
instance or server is well worth the time invested up front to support them
all.
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006|||That's a major advantage - the ability to parse off a large client onto
another server as required. Taking it to the next level, let's say you have
those 400+ DB's on 4 servers. You can then move DB's from one box to
another to level the load. Sur, it's manual, but if you take regular
performance stats, you are then in a good position to figure out who goes
where.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in mess
age
news:OvZbmStpHHA.3512@.TK2MSFTNGP06.phx.gbl...
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:uRUj1fspHHA.2156@.TK2MSFTNGP03.phx.gbl...
> Then, if you go the one DB per client route, you'll need to automate your
> maintenance processes, e.g. backup, reindexing and the like. It's not
> that
> big of a problem; you just need to have it in place.
I'm doing this for 400+ databases in two systems, and the maintenance stuff
is a one-time cost. The ability to move a resource-hoggy client to its own
instance or server is well worth the time invested up front to support them
all.
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006

One database or many database?

I have a web application which collect data from MANY clients. Data
collected is in the same structure, my questions is: to use one database
store all data or create a database for each client? which way is better?
Thank you
QuinnThere is no right or wrong answer here. If you have one huge DB, then
backup and recovery can be problematic. If you have 100's of small DB's,
then it becomes an administrative challenge, though much admin can be
automated/scripted.
There are also security issues. Some clients refuse to commingle their data
with other companies.
Also, if you needed to separate a client into its own DB on another server,
it's not straightforward. Whereas, if you have each client in it's own DB,
it's just a matter of backup and restore.
If the number of clients that you have is small, then likely you can get
away with a single DB.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Quinn" <qjia@.yahoo.com> wrote in message
news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
I have a web application which collect data from MANY clients. Data
collected is in the same structure, my questions is: to use one database
store all data or create a database for each client? which way is better?
Thank you
Quinn|||Thank you Tom.
Right now I don't know how many clients yet, but 500+- may close enough.
Quinn
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23G8mcPspHHA.4212@.TK2MSFTNGP04.phx.gbl...
> There is no right or wrong answer here. If you have one huge DB, then
> backup and recovery can be problematic. If you have 100's of small DB's,
> then it becomes an administrative challenge, though much admin can be
> automated/scripted.
> There are also security issues. Some clients refuse to commingle their
> data
> with other companies.
> Also, if you needed to separate a client into its own DB on another
> server,
> it's not straightforward. Whereas, if you have each client in it's own
> DB,
> it's just a matter of backup and restore.
> If the number of clients that you have is small, then likely you can get
> away with a single DB.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Quinn" <qjia@.yahoo.com> wrote in message
> news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
> I have a web application which collect data from MANY clients. Data
> collected is in the same structure, my questions is: to use one database
> store all data or create a database for each client? which way is better?
>
> Thank you
> Quinn
>|||Then, if you go the one DB per client route, you'll need to automate your
maintenance processes, e.g. backup, reindexing and the like. It's not that
big of a problem; you just need to have it in place.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Quinn" <qjia@.yahoo.com> wrote in message
news:OceHgUspHHA.4772@.TK2MSFTNGP05.phx.gbl...
Thank you Tom.
Right now I don't know how many clients yet, but 500+- may close enough.
Quinn
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23G8mcPspHHA.4212@.TK2MSFTNGP04.phx.gbl...
> There is no right or wrong answer here. If you have one huge DB, then
> backup and recovery can be problematic. If you have 100's of small DB's,
> then it becomes an administrative challenge, though much admin can be
> automated/scripted.
> There are also security issues. Some clients refuse to commingle their
> data
> with other companies.
> Also, if you needed to separate a client into its own DB on another
> server,
> it's not straightforward. Whereas, if you have each client in it's own
> DB,
> it's just a matter of backup and restore.
> If the number of clients that you have is small, then likely you can get
> away with a single DB.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Quinn" <qjia@.yahoo.com> wrote in message
> news:OLqpwLspHHA.2596@.TK2MSFTNGP06.phx.gbl...
> I have a web application which collect data from MANY clients. Data
> collected is in the same structure, my questions is: to use one database
> store all data or create a database for each client? which way is better?
>
> Thank you
> Quinn
>|||"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:uRUj1fspHHA.2156@.TK2MSFTNGP03.phx.gbl...
> Then, if you go the one DB per client route, you'll need to automate your
> maintenance processes, e.g. backup, reindexing and the like. It's not
> that
> big of a problem; you just need to have it in place.
I'm doing this for 400+ databases in two systems, and the maintenance stuff
is a one-time cost. The ability to move a resource-hoggy client to its own
instance or server is well worth the time invested up front to support them
all.
--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006|||That's a major advantage - the ability to parse off a large client onto
another server as required. Taking it to the next level, let's say you have
those 400+ DB's on 4 servers. You can then move DB's from one box to
another to level the load. Sur, it's manual, but if you take regular
performance stats, you are then in a good position to figure out who goes
where.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:OvZbmStpHHA.3512@.TK2MSFTNGP06.phx.gbl...
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:uRUj1fspHHA.2156@.TK2MSFTNGP03.phx.gbl...
> Then, if you go the one DB per client route, you'll need to automate your
> maintenance processes, e.g. backup, reindexing and the like. It's not
> that
> big of a problem; you just need to have it in place.
I'm doing this for 400+ databases in two systems, and the maintenance stuff
is a one-time cost. The ability to move a resource-hoggy client to its own
instance or server is well worth the time invested up front to support them
all.
--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006

Monday, March 26, 2012

One Application With 2 DataBase

Hai All ,

Iam having the one Application in DotNet2005.But iam using the two database(SqlServer2005).If user's login the application it will check credentials in first database, if he is not having the login credentials it will cheek the second Database. How can I handle in the configuration file?. How can I change the connection string depending upon the Database in my application for database operation (like insert and update).Any one kindly provide the solution.

Thanks and regards,sureshK

you can have 2 separate connection string in web.config file, appsetting section like

<add key="loginConnectionString" value = "" />

<add key="ConnectionString" value="" />

you can check have a Session Variable named as "CurrentLogin" where you can store the ID or Name or anything user related information after successful login.. if user is logged in.. then that Session Variable must having Some Value.. you can check that value and;... set and use required Connection String by you... hope i got your situation...

|||

Hai Thank You. Your answer is exactly Correct. If their is any other way to achieve this?.

With Regards,

SureshK.|||

Hi mskumarmca,

Just askaushalparik27 has suggested above, you can use two different connection string to connect to 2 databases, and in your code behind, first build one connecton to the first database and execute your query. If the specific username/password has been found, it indicates that the current user is registered in the first dabase. And if not, you can build another connection to the second database and execute the same query likewise.

A small tip here: you can provide 2 check boxes in the page UI, giving users a change to select on which database they would like to verify their credential. This should be much helpful to enhance your site performance.

Hope my suggestion helps

|||

Hi thank for your tips.

Yes I get database name and passing the database name as parameter and finished.

But I am trying to keep the Database name in session. But I am not able to get that session value in my BL layer.

For change the connection string for further database operations. Below code was I am trying to get database value in BL Layer class file. But the session value is set as Null. What is the problem?

String DBName=(String)System.Web.HttpContext.Current.Session["DBNAME"];

Kindly give me the idea. Regards,SureshK|||

where and how did you store that DBNAME into your session variables?

|||

Hi thanks for your reply,

When the user log in the application. I will connect through default connection string with DB1.

I have one SP to check login cardinals in DB1 and DB2 and it will return the login cardinals and connection string name.

if user name is DB1 I am going to use ConsStr1 else Constr2. That Connection string value in login page.

Session["DBNAME"] = dsLogin.Tables[0].Rows[0][DBNAME].ToString();

Above session value only i need to access in my business logic layer.

Regards,

SureshK

|||

Hai all I Got the answer.

In BL Class file .

Import the namesapce.

using System.Web.SessionState;

And Following is to access the session Variable.

string SapId = (String)System.Web.HttpContext.Current.Session["session variale name in asp.cs"];

one ado connection object - multiple spids?

Hi,
We have asp application (ado connection) which connects to the sql server
2000 (sp3). There is one asp page which sequentially executes set of 6
stored procedures. When I execute same set of stored procedures in query
analyzer, I get response in less than 1 second.When application does that,
response gets back in 15-20 seconds (only when we have problem, otherwise in
2-3 seconds). In the trace, I noticed that each of these 6 stored procedures
(which btw use 1 connection object) gets a different SPID. Why is that?
Shouldn't they use the same SPID, if they use the same connection object
(executed sequentially!)?
Also, the trace shows that each of them gets executed almost instantly
(1ms), but between end of previous, and beginning of the next one, there is
delay of 2-3 seconds. During these 2-3 seconds, there is nothing going on on
the database server (very few events).
Does anybody have an idea?
ThanksPedja wrote:
> Hi,
> We have asp application (ado connection) which connects to the sql
> server 2000 (sp3). There is one asp page which sequentially executes
> set of 6 stored procedures. When I execute same set of stored
> procedures in query analyzer, I get response in less than 1
> second.When application does that, response gets back in 15-20
> seconds (only when we have problem, otherwise in 2-3 seconds). In the
> trace, I noticed that each of these 6 stored procedures (which btw
> use 1 connection object) gets a different SPID. Why is that?
> Shouldn't they use the same SPID, if they use the same connection
> object (executed sequentially!)? Also, the trace shows that each of them
> gets executed almost instantly
> (1ms), but between end of previous, and beginning of the next one,
> there is delay of 2-3 seconds. During these 2-3 seconds, there is
> nothing going on on the database server (very few events).
> Does anybody have an idea?
> Thanks
Are you sure you are not closing the connection and opening it up each time
your ASP code executed some SQL?
David Gugick
Quest Softwaresql

Friday, March 23, 2012

On any change or update

I am wiriting a C# application that stores availabilty information in a tabl
e
ie UserName, UserAvailable (just to keep it simple)
I am looking for a recommendation for the best way to have the SQL database
notify my c# client that any data in this table has been changed.
In my old non .net application I used a client/server model where the
server watched for changes and sent messages to each registered client but n
o
data was ever saved. Two of my goals with the new application are eliminatin
g
the server application and saving the data to a SQL db.
Currently I have my application re-examine the table every n-seconds but
this is far from optimal. Any suggestions would be highly appreciated.
Regards,
SeanHi
What is your SQL Server vesion?
If it is SQL Server 2000 , I think you may want to consider using triggers
to examine "deleted" and "inserted" virtual tables
Does your App make changes too?
"Codesmith" <Codesmith@.discussions.microsoft.com> wrote in message
news:8F93298C-EBD9-4CE4-A7C9-8DA9E9731908@.microsoft.com...
>I am wiriting a C# application that stores availabilty information in a
>table
> ie UserName, UserAvailable (just to keep it simple)
> I am looking for a recommendation for the best way to have the SQL
> database
> notify my c# client that any data in this table has been changed.
> In my old non .net application I used a client/server model where the
> server watched for changes and sent messages to each registered client but
> no
> data was ever saved. Two of my goals with the new application are
> eliminating
> the server application and saving the data to a SQL db.
> Currently I have my application re-examine the table every n-seconds but
> this is far from optimal. Any suggestions would be highly appreciated.
> Regards,
> Sean|||If you are on, or can upgrade to, SQL Serer 2005, read up on Query Notificat
ions.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Codesmith" <Codesmith@.discussions.microsoft.com> wrote in message
news:8F93298C-EBD9-4CE4-A7C9-8DA9E9731908@.microsoft.com...
>I am wiriting a C# application that stores availabilty information in a tab
le
> ie UserName, UserAvailable (just to keep it simple)
> I am looking for a recommendation for the best way to have the SQL databas
e
> notify my c# client that any data in this table has been changed.
> In my old non .net application I used a client/server model where the
> server watched for changes and sent messages to each registered client but
no
> data was ever saved. Two of my goals with the new application are eliminat
ing
> the server application and saving the data to a SQL db.
> Currently I have my application re-examine the table every n-seconds but
> this is far from optimal. Any suggestions would be highly appreciated.
> Regards,
> Sean|||There are many approaches for implementing that, the best and sexiest
solution is to use Query Notification as Tibor said. There are other
mechanisms for doing this (including calling Message Queues...), but
not as easy to use as QN :-)
HTH, jens Suessmeyer.|||Tibor,
Thanks for your responce. After reviewing the documentaion on the MSDN web
page this sounds like just what I had in mind.
Do you know if the service broker feature is available in the 2005 Express
edition of SQL?
"Tibor Karaszi" wrote:

> If you are on, or can upgrade to, SQL Serer 2005, read up on Query Notific
ations.
>|||Hi,
http://www.microsoft.com/sql/prodin...e-features.mspx
Service Broker (Subscriber only) --means yes, you can.
HTH, Jens Suessmeyer.|||Hi Jens!
the way I read the part "subscriber only" is that you cannot insert into a q
ueue on Express. To me,
this sounds like Express does not support query notifications. But I happily
admit that I'm only
guessing here. ;-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1136912680.595505.22710@.g43g2000cwa.googlegroups.com...
> Hi,
> http://www.microsoft.com/sql/prodin...e-features.mspx
> Service Broker (Subscriber only) --means yes, you can.
>
> HTH, Jens Suessmeyer.
>|||You are right I just read down the white paper, you can subscribe
within broker queues outside the SQL Server Express Editions, so you
just can be notified. So even default queues are not creaetable. Sorry
for the wrong information to the original poster, thanks to Tibor.
-Jens.|||Service Broker is available in SQL Express 2005.
The only restriction is that when exchanging messages between separate SQL
instances, the message has to pass trough a higher version. That is, you
cannot send a message from a SQL Express to another SQL Express directly.
Since you're interested in Query Notifications, you will probably keep the
messages local within the SQL Express instance, so this limitation won't
affect you whatsoever.
This posting is provided "AS IS" with no warranties, and confers no rights.
HTH,
~ Remus Rusanu
SQL Service Broker
http://msdn2.microsoft.com/en-us/library/ms166043(en-US,SQL.90).aspx
"Codesmith" <Codesmith@.discussions.microsoft.com> wrote in message
news:7DF1F9B5-19F0-4E41-AA75-D2B19DA5EE7B@.microsoft.com...
> Tibor,
> Thanks for your responce. After reviewing the documentaion on the MSDN web
> page this sounds like just what I had in mind.
> Do you know if the service broker feature is available in the 2005 Express
> edition of SQL?
>
> "Tibor Karaszi" wrote:
>|||Sorry, not true Tibor. The short story is that as long as you are working
within the same instance (which is the only way query notifications work
with the default listener) SQL Express Service Broker is 100% equivalent to
all the other SKU's. If you are talking between sku's, there is a small
restriction as Remus pointed out.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:uiQOc2gFGHA.3280@.TK2MSFTNGP10.phx.gbl...
> Hi Jens!
> the way I read the part "subscriber only" is that you cannot insert into a
> queue on Express. To me, this sounds like Express does not support query
> notifications. But I happily admit that I'm only guessing here. ;-)
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1136912680.595505.22710@.g43g2000cwa.googlegroups.com...
>

Omitted characters after importing XML file with SQLXMLBulkLoad

When importing data in my C# application with the SQLXML4's SQLXMLBulkLoad library, I noticed that if my data has 2 ampersands seperated by space, it will be imported into the SQL table without the spaces. It doesn't matter how many spaces are there, it will remove all of them. I have verified that the spaces exist in the XML file and the ampersands are properly escaped as "&amp;".

Example:

XML Field Value: '&amp; &amp;'
Expected SQL Field Value: '& &'
Resulting SQL Field Value: '&&'

Let me know if you need any additional information.

EDIT: I apologize if this is in the wrong forum. Since it is related to SQL XML Bulkload, I felt this was a better place than the C# forum.
Have I posted this in the wrong forum? I need an answer to this soon.
|||

Hello,

I wasn't able to repro your problem.Here is the xmldata I used:

<test xmldata="&amp; &amp;"/>

and this is what I get in the database:

xmldata

--

& &

If I run this query in QA:

select * from test for xml auto

I get back:

<test xmldata="&amp; &amp;"/>

Could you send me the schema and the data file you used?

Thanks,

Monica

|||One difference I see in the xml sample you used is I am using an actual value instead of an attribute. For example:

<Document>&amp; &amp;</Document>

This field (Document) is going into the SQL table's field name [Document] which has its data type set as text. I have not tried importing it into a varchar to see if that makes a difference as that is not really an option I have.
|||

Hello,

I was able to repro your problem and it looks like this is the current behavior.

The solution for preserving the whitespace would be to wrap the data inside a CDATA element.

I hope this helps.

Best regards,

Monica

|||holuilhello! how can i use the SQLXMLBulkLoad in c#? when i reference the microsoft.data.xml namespace, i can not use the SQLXMLBulkLoad.hello! how can i use the SQLXMLBulkLoad in c#? when i reference the microsoft.data.xml namespace, i can not use the SQLXMLBulkLoad.

Omitted characters after importing XML file with SQLXMLBulkLoad

When importing data in my C# application with the SQLXML4's SQLXMLBulkLoad library, I noticed that if my data has 2 ampersands seperated by space, it will be imported into the SQL table without the spaces. It doesn't matter how many spaces are there, it will remove all of them. I have verified that the spaces exist in the XML file and the ampersands are properly escaped as "&amp;".

Example:

XML Field Value: '&amp; &amp;'
Expected SQL Field Value: '& &'
Resulting SQL Field Value: '&&'

Let me know if you need any additional information.

EDIT: I apologize if this is in the wrong forum. Since it is related to SQL XML Bulkload, I felt this was a better place than the C# forum.
Have I posted this in the wrong forum? I need an answer to this soon.
|||

Hello,

I wasn't able to repro your problem.Here is the xmldata I used:

<test xmldata="&amp; &amp;"/>

and this is what I get in the database:

xmldata

--

& &

If I run this query in QA:

select * from test for xml auto

I get back:

<test xmldata="&amp; &amp;"/>

Could you send me the schema and the data file you used?

Thanks,

Monica

|||One difference I see in the xml sample you used is I am using an actual value instead of an attribute. For example:

<Document>&amp; &amp;</Document>

This field (Document) is going into the SQL table's field name [Document] which has its data type set as text. I have not tried importing it into a varchar to see if that makes a difference as that is not really an option I have.
|||

Hello,

I was able to repro your problem and it looks like this is the current behavior.

The solution for preserving the whitespace would be to wrap the data inside a CDATA element.

I hope this helps.

Best regards,

Monica

|||holuilhello! how can i use the SQLXMLBulkLoad in c#? when i reference the microsoft.data.xml namespace, i can not use the SQLXMLBulkLoad.hello! how can i use the SQLXMLBulkLoad in c#? when i reference the microsoft.data.xml namespace, i can not use the SQLXMLBulkLoad.sql

Omitted characters after importing XML file with SQLXMLBulkLoad

When importing data in my C# application with the SQLXML4's SQLXMLBulkLoad library, I noticed that if my data has 2 ampersands seperated by space, it will be imported into the SQL table without the spaces. It doesn't matter how many spaces are there, it will remove all of them. I have verified that the spaces exist in the XML file and the ampersands are properly escaped as "&amp;".

Example:

XML Field Value: '&amp; &amp;'
Expected SQL Field Value: '& &'
Resulting SQL Field Value: '&&'

Let me know if you need any additional information.

EDIT: I apologize if this is in the wrong forum. Since it is related to SQL XML Bulkload, I felt this was a better place than the C# forum.
Have I posted this in the wrong forum? I need an answer to this soon.
|||

Hello,

I wasn't able to repro your problem.Here is the xmldata I used:

<test xmldata="&amp; &amp;"/>

and this is what I get in the database:

xmldata

--

& &

If I run this query in QA:

select * from test for xml auto

I get back:

<test xmldata="&amp; &amp;"/>

Could you send me the schema and the data file you used?

Thanks,

Monica

|||One difference I see in the xml sample you used is I am using an actual value instead of an attribute. For example:

<Document>&amp; &amp;</Document>

This field (Document) is going into the SQL table's field name [Document] which has its data type set as text. I have not tried importing it into a varchar to see if that makes a difference as that is not really an option I have.
|||

Hello,

I was able to repro your problem and it looks like this is the current behavior.

The solution for preserving the whitespace would be to wrap the data inside a CDATA element.

I hope this helps.

Best regards,

Monica

|||holuilhello! how can i use the SQLXMLBulkLoad in c#? when i reference the microsoft.data.xml namespace, i can not use the SQLXMLBulkLoad.hello! how can i use the SQLXMLBulkLoad in c#? when i reference the microsoft.data.xml namespace, i can not use the SQLXMLBulkLoad.

Olympic Games Support in Torino 2006

We are utilizing a .net front end Client side application to access a remote
SQL database. We will be using this method for transactions locally to issue
apparel to Athletes as well as other information about our team. The
question I have is our proposed setup is to have a 2MB line using a VPN
connection back to our home site and conduct live application entry, we will
then have a local client facing server in Italy for disaster recovery
performing stored procedures to trigger replication for a backup copy. We
proposed this topology as other members need real time access to the data at
multiple locations. Are main concerns are survivability of the database and
potential latency issues over a leased line. Anyone have any thoughts?
I wouldn't use stored procedures for that but setup replication.
In case the link fails you have disconnected systems that can operate
independent from eachother and when the connection comes back up replication
will occur.
There are several replication topologies and methods possible.
This will depend on the amount of data you want to replicate as well.
Thinking of snapshot replication or transactional replication
Probably transactional with immediate updating subscribers might be the
option.
Dandy Weyn
[MCSE-MCSA-MCDBA-MCDST-MCT]
http://www.dandyman.net
Check my SQL Server Resource Pages at http://www.dandyman.net/sql
"Paul Walker" <Paul Walker@.discussions.microsoft.com> wrote in message
news:5488F052-E627-415C-AD93-545D726BA28F@.microsoft.com...
> We are utilizing a .net front end Client side application to access a
> remote
> SQL database. We will be using this method for transactions locally to
> issue
> apparel to Athletes as well as other information about our team. The
> question I have is our proposed setup is to have a 2MB line using a VPN
> connection back to our home site and conduct live application entry, we
> will
> then have a local client facing server in Italy for disaster recovery
> performing stored procedures to trigger replication for a backup copy. We
> proposed this topology as other members need real time access to the data
> at
> multiple locations. Are main concerns are survivability of the database
> and
> potential latency issues over a leased line. Anyone have any thoughts?

Wednesday, March 21, 2012

OleDbException ErrorCode

When a user finally confirms his order in a shopping cart application (using MS-Access as the backend), the items he has purchased are populated in a Access DB table namedOrders & his personal details (like name, mail, billing address, shipping address etc.) are populated in another table namedCustDetails. Both the DB tables have a column namedOrderID. This column is thePrimary Key in theCustDetails table & theForeign Key in theOrders table. TheSession.SessionID becomes the unique OrderID.

After confirming an order, if the user refreshes the page, the app will try to populate the sameSession.SessionID in theCustDetails table but since the columnOrderID is aPrimary Key column in the tableCustDetails, it won't accept duplicate OrderIDs. Under such circumstances, anOleDbException will be raised.

Since a DB app can throw otherOleDbExceptions other than the one about which I mentioned above, I want to display custom error messages to the user. For e.g. if he refreshes the page after confirming his order, I want to display a message saying "Your order has already been placed".

To do this, I tried using theErrorCode property of theOleDbException class but what I found is theErrorCode changes from time to time! Had a particularErrorCode been assigned to the error, I could have done something like this (assuming that theErrorCode for the above error is-12345 which is constant):

Try
'some code
Catch ex As OleDbException
If (ex.ErrorCode = -12345) Then
Response.Write("Your order has already been placed")
ElseIf (ex.ErrorCode = <some other constant ErrorCode>) Then
Response.Write("Another custom error message")
End If
End Try

But I can't do the above since theErrorCode changes from time to time.

So how do I display custom error messages to users under such circumstances?

Of course, I can use theMessage property of theOleDbException class but that would be a rather tedious workaround.

I would provide user friendly messages for the the common errors in a shared function.

There are too many error codes to redefine them all. Putting the code in a central function allows you to call it from anywhere (excuse my C# but you get the idea)

String ExceptionToFriendlyString(OldDbExcption Ex){switch(Ex.ErrorCode) {case 1234:return"That record has already been inserted";case 5678:return"Friendly error message";default:return Ex.Message; // default to Exception Message }}

|||Thanks for your suggestion, Steve, but as already pointed in post #1 in this thread, the ErrorCode goes on changing. For e.g. when I try to insert a record in a DB table that already exists in that DB table, the ErrorCode turns out to be, say, 1234.

Next I shut down my machine & restart it. Now when I try to insert a record in the same DB table which already exists in the table, then the ErrorCode changes to, say, 5678. Of course, I can use a default message as you have shown in your code but (again) as already pointed out, I want the error messages to be as precise as possible.

Any other suggestions?|||

I think you will find that the reason you are getting different error codes is because you are getting different errors.

|||

Hi RN5A,

I agree that the error code stays fixed when you get certain kind of error. When error code changes, the type of error gets changed.

OleDbCommand with Parameters

Hi,

I have application connected to MS Access DB using OleDB. When creating commands (Insert/Update/Select) I use OleDbParamater class to insert data into command. Examples :

Select ::

OleDbCommand select_cmd = new OleDbCommand("SELECT * FROM " + ObjectTable.TableName + " WHERE " +
ObjectTable.idObject + "=@." + ObjectTable.idObject + " AND " +
ObjectTable.idObjectUnder + "=@." + ObjectTable.idObjectUnder);

Update ::

OleDbCommand update_cmd = new OleDbCommand("Update " + ObjectTable.TableName + " SET " +
ObjectTable.idParent + "=@." + ObjectTable.idParent + " , " +
ObjectTable.idParentUnder + "=@." + ObjectTable.idParentUnder + " , " +
ObjectTable.License + "=@." + ObjectTable.License + " , " +
ObjectTable.Type + "=@." + ObjectTable.Type + " ," +
ObjectTable.Language + "=@." + ObjectTable.Language + " , " +
ObjectTable.Name + "=@." + ObjectTable.Name + " , " +
ObjectTable.Checksum + "=@." + ObjectTable.Checksum + " , " +
ObjectTable.VText + "=@." + ObjectTable.VText + " , " +
ObjectTable.VInt + "=@." + ObjectTable.VInt + " WHERE " +
ObjectTable.idObject + "=@." + ObjectTable.idObject + " AND " +
ObjectTable.idObjectUnder + "=@." + ObjectTable.idObjectUnder);

Parametes:: (Adding in separate method -> AddParameters(OleDbCommand command); )

command.Parameters.Add("@." + ObjectTable.idObject, OleDbType.BigInt).Value = this.IDUpper;
command.Parameters.Add("@." + ObjectTable.idObjectUnder, OleDbType.BigInt).Value = this.IDUnder;
command.Parameters.Add("@." + ObjectTable.Name, OleDbType.VarChar).Value = this.Name;
command.Parameters.Add("@." + ObjectTable.idParent, OleDbType.BigInt).Value = GetUpper(this.IDParent);
command.Parameters.Add("@." + ObjectTable.idParentUnder, OleDbType.BigInt).Value = GetUnder(this.IDParent);
command.Parameters.Add("@." + ObjectTable.License, OleDbType.BigInt).Value = this.License;
command.Parameters.Add("@." + ObjectTable.Language, OleDbType.BigInt).Value = this.Language;
command.Parameters.Add("@." + ObjectTable.Type, OleDbType.BigInt).Value = (int)this.Type;

command.Parameters.Add("@." + ObjectTable.VText, OleDbType.VarChar).Value = String.IsNullOrEmpty(this.VText) ? null : this.VText;
command.Parameters.Add("@." + ObjectTable.VInt, OleDbType.BigInt).Value = this.VInt;
command.Parameters.Add("@." + ObjectTable.Checksum, OleDbType.BigInt).Value = this.Checksum;

Question: Does the order of adding parameters to command matter? Because allways when the order of parameters added is diffrent from order in command text, I get weird Exceptions . I thought that the name matters, not the order, but it seems that system doesn't care about the parameter's name, it just picks next parameter in command.Parameters when putting values. How is it?Do you mean that if it could matter during the addition of the parameters ? It does not, as the .add method only puts the parameter in the collection.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||You know what? It does. And it is the only thing that matters (talking about OleDb) -> ORDER. Despite of using names (I could questionmarks instead of parameter's names). I've done this using Oracle DB and (of cource) namespace and everything worked fine, but OleDb looks to handle thing in it's own weird way. Example :

OleDbCommand selectCmd = new OleDbCommand( "Select * from Customers where CustomerName=@.name AND CustomerAge=@.age);

selectCmd.Parameters.Add("@.age", OleDbType.Integer).Value = 20;

selectCmd.Parameters.Add("@.name", OleDbType.VarChar).Value = "Michael";

this is NOT going to work !!! If the order of parameters added to command's parameters collection is diffrent from order of parameters used in command itself, it won't work.

OLEDB TRANSACTION MAKING DIFFERENCE and error is raised

OLEDB transaction is making difference in my migrated application powerbuilder 10.5 which has new oledb driver which is replaced by MSS driver in previous Powerbuilder version.

1.)I am facing the below error on update/save this was not faced during my previous versino drive MSS in powerbuilder.This is oocure only after the change to oledb driver.

"Row change between retrieve and update.".

in front end of my application the error is poped as

"(STD1007) This row has been modified by another user. Save is canceled! ".

Please help to resolve this error.

Are you seeing this error when using Integration Services? If so, can you give more information on all the database access (e.g. ExecuteSQL, OLE DB Destination) in your package? If not, and this is specific to Powerbuilder, then I would start by looking at any settings available in your front end for handling database changes and transaction isolation level. If you want to focus on the provider itself, you can ask your question on the SQL Server Data Access forum, but they will likely have to rely on you to know how Powerbuilder is using the provider under the covers.

Tuesday, March 20, 2012

OleDB not returning a empty cursor.

I am using SQLServer 2000 on multiple Windows operating systems and
the application accessing the database are also on multiple Windows
OSs namely Windows 2000 server, Windows 2003 Server, Windows 2000 and
Windows XP. The issue is only noticed when the database resides on
windows 2003 box. The application uses a single connection to call 4
stored procedures sequentially. The first 3 stored procedures do not
return any cursor (just parameter info). But the 4th stored proc is
expected to return a cursor with 0 or more records. When this app is
executed against a SQL server residing on a 2000 server, it returns a
rowset with no rows but all the metadata information is available
(cursor field names).
But in case of Windows 2003 box, when the stored proc has no records
to return (empty cursor), the rowset is set to nil. Basically as part
of the OleDb interface I am calling ICommand
HRESULT Execute (
IUnknown *pUnkOuter,
REFIID riid,
DBPARAMS *pParams,
DBROWCOUNT *pcRowsAffected,
IUnknown **ppRowset);\
In the 2000 server, the IUnknown is a pointer after the execution, but
in 2003, the value is nil. Does anyone know if the SQLServer provider
has been modified to return a nil in case of a empty cursor or is this
a bug? Also if anyone knows of any work arounds or fixes, I would
greatly appreciate it if you could share it with me.
The 2003 box has MDAC 2.8 RTM, while the rest of the boxes have MDAC
2.7x.
Thanks,
SubraSubra (subramanyan.ramanathan@.gmail.com) writes:
> I am using SQLServer 2000 on multiple Windows operating systems and
> the application accessing the database are also on multiple Windows
> OSs namely Windows 2000 server, Windows 2003 Server, Windows 2000 and
> Windows XP. The issue is only noticed when the database resides on
> windows 2003 box. The application uses a single connection to call 4
> stored procedures sequentially. The first 3 stored procedures do not
> return any cursor (just parameter info). But the 4th stored proc is
> expected to return a cursor with 0 or more records. When this app is
> executed against a SQL server residing on a 2000 server, it returns a
> rowset with no rows but all the metadata information is available
> (cursor field names).
> But in case of Windows 2003 box, when the stored proc has no records
> to return (empty cursor), the rowset is set to nil. Basically as part
> of the OleDb interface I am calling ICommand
> HRESULT Execute (
> IUnknown *pUnkOuter,
> REFIID riid,
> DBPARAMS *pParams,
> DBROWCOUNT *pcRowsAffected,
> IUnknown **ppRowset);\
> In the 2000 server, the IUnknown is a pointer after the execution, but
> in 2003, the value is nil. Does anyone know if the SQLServer provider
> has been modified to return a nil in case of a empty cursor or is this
> a bug? Also if anyone knows of any work arounds or fixes, I would
> greatly appreciate it if you could share it with me.
It is not really clear to me. Do you get this problem when you connect
to the SQL Server residing on the Windows 2003 box, no matter which
operating system the client is on?
If that is the case, I can't see that MDAC versions has anything to
do with it, but there is something on the server, that is causing the
NULL pointer.
A few more questions:
o If the stored procedure returns data, do you get a pointer in this
case?
o What is the return code of ICommand::Execute?
o What do you pass for REFIID?
o You talk about cursor. Is that a really true server-side cursor, or
is it just a result set that you get back?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thank you for the response.
Yes, the issue happens when I connect to a SQL server residing on a
Windows 2003 box, regardless of the O/s the app is on (have tried
running the app on Windows 2003 and Windows XP).
o If the stored procedure returns data, do you get a pointer in this
case? - Yes, I do get a pointer when a recordset is present.
o What is the return code of ICommand::Execute? - The return code is
0, which means successful
o What do you pass for REFIID? - IID_IUnknown: TGUID =
'{00000000-0000-0000-C000-000000000046}';
o You talk about cursor. Is that a really true server-side cursor,
or
is it just a result set that you get back? - It is just a
resultset.
Thank you.
Subra.
Erland Sommarskog <esquel@.sommarskog.se> wrote in message news:<Xns9599EFD3E715FYazorman@.127
.0.0.1>...
> Subra (subramanyan.ramanathan@.gmail.com) writes:
> It is not really clear to me. Do you get this problem when you connect
> to the SQL Server residing on the Windows 2003 box, no matter which
> operating system the client is on?
> If that is the case, I can't see that MDAC versions has anything to
> do with it, but there is something on the server, that is causing the
> NULL pointer.
> A few more questions:
> o If the stored procedure returns data, do you get a pointer in this
> case?
> o What is the return code of ICommand::Execute?
> o What do you pass for REFIID?
> o You talk about cursor. Is that a really true server-side cursor, or
> is it just a result set that you get back?|||Subra (subramanyan.ramanathan@.gmail.com) writes:
> Thank you for the response.
> Yes, the issue happens when I connect to a SQL server residing on a
> Windows 2003 box, regardless of the O/s the app is on (have tried
> running the app on Windows 2003 and Windows XP).
> o If the stored procedure returns data, do you get a pointer in this
> case? - Yes, I do get a pointer when a recordset is present.
> o What is the return code of ICommand::Execute? - The return code is
> 0, which means successful
> o What do you pass for REFIID? - IID_IUnknown: TGUID =
> '{00000000-0000-0000-C000-000000000046}';
> o You talk about cursor. Is that a really true server-side cursor,
> or
> is it just a result set that you get back? - It is just a
> resultset.
What strikes me as odd is the use if IID_IUnknown. Normally you would
use IID_IRowset or IID_IMultipleResults. I don't know if this has anything
to do with it.
But since the error is independent of which OS the client is on, I am
more inclined to think that there is a difference between the code
running on the two SQL Servers, or the their configuration. I can't
see that the MDAC version should matter.
Could you post the code for the stored procedure? Preferably take it from
the Win2003 database. Also the C++ code from where you create the
command up to the point of execution helps. There are a few variations
with prepared statements, calling syntax etc. It is difficult to recreate
you scenario, without knowing what you are doing.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland,
I managed to figure out the issue just recently. The reason for the
issue is that in the stored proc that had the issue, I am using some
temp tables to return data. Supposedly in the newer version of SQL
Server OLEDB provider (SQLOLEDB) they return a result of each
statement that gets executed in the stored proc. This and the
combination of having temp tables in the stored proc results in some
errors and hence no cursor is returned. So the recommended fix for
this issue is to have the setting "SET NOCOUNT ON". I am attaching a
link to the article on the microsoft website.
http://support.microsoft.com/defaul...kb;en-us;235340
Thank you for your assistance.
Regards,
Subra.
Erland Sommarskog <esquel@.sommarskog.se> wrote in message news:<Xns959CD7F71B5EFYazorman@.127
.0.0.1>...
> Subra (subramanyan.ramanathan@.gmail.com) writes:
> What strikes me as odd is the use if IID_IUnknown. Normally you would
> use IID_IRowset or IID_IMultipleResults. I don't know if this has anything
> to do with it.
> But since the error is independent of which OS the client is on, I am
> more inclined to think that there is a difference between the code
> running on the two SQL Servers, or the their configuration. I can't
> see that the MDAC version should matter.
> Could you post the code for the stored procedure? Preferably take it from
> the Win2003 database. Also the C++ code from where you create the
> command up to the point of execution helps. There are a few variations
> with prepared statements, calling syntax etc. It is difficult to recreate
> you scenario, without knowing what you are doing.|||Subra (subramanyan.ramanathan@.gmail.com) writes:
> I managed to figure out the issue just recently. The reason for the
> issue is that in the stored proc that had the issue, I am using some
> temp tables to return data. Supposedly in the newer version of SQL
> Server OLEDB provider (SQLOLEDB) they return a result of each
> statement that gets executed in the stored proc. This and the
> combination of having temp tables in the stored proc results in some
> errors and hence no cursor is returned. So the recommended fix for
> this issue is to have the setting "SET NOCOUNT ON". I am attaching a
> link to the article on the microsoft website.
> http://support.microsoft.com/defaul...kb;en-us;235340
Glad to hear that you were able to resovle the issue!
There is not really any change in the basic behaviour. By default SQL
Server returns a "rows affected" message for each INSERT, DELETE and UPDATE
statement. With most client libraries you get this as count without a result
set. If your code does not handle this, and only looks for the first result
set, all you get is the first "rows affected" message, but no rowset pointer
or the equivalent.
In many cases, these rowcounts are of little interest, so submitting SET
NOCOUNT ON, kills two birds with two stones: you get the data you are
looking for in the first result set, and you improve performance, since
you reduce network traffic.
My recommendation, though, is to use IMultipleResults and get all result
sets, anyway. This makes the code more robust, not the least with regards
to catching errors and PRINT messages.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

OleDB not returning a empty cursor.

I am using SQLServer 2000 on multiple Windows operating systems and
the application accessing the database are also on multiple Windows
OSs namely Windows 2000 server, Windows 2003 Server, Windows 2000 and
Windows XP. The issue is only noticed when the database resides on
windows 2003 box. The application uses a single connection to call 4
stored procedures sequentially. The first 3 stored procedures do not
return any cursor (just parameter info). But the 4th stored proc is
expected to return a cursor with 0 or more records. When this app is
executed against a SQL server residing on a 2000 server, it returns a
rowset with no rows but all the metadata information is available
(cursor field names).
But in case of Windows 2003 box, when the stored proc has no records
to return (empty cursor), the rowset is set to nil. Basically as part
of the OleDb interface I am calling ICommand
HRESULT Execute (
IUnknown *pUnkOuter,
REFIID riid,
DBPARAMS *pParams,
DBROWCOUNT *pcRowsAffected,
IUnknown **ppRowset);\
In the 2000 server, the IUnknown is a pointer after the execution, but
in 2003, the value is nil. Does anyone know if the SQLServer provider
has been modified to return a nil in case of a empty cursor or is this
a bug? Also if anyone knows of any work arounds or fixes, I would
greatly appreciate it if you could share it with me.
The 2003 box has MDAC 2.8 RTM, while the rest of the boxes have MDAC
2.7x.
Thanks,
Subra
Subra (subramanyan.ramanathan@.gmail.com) writes:
> I am using SQLServer 2000 on multiple Windows operating systems and
> the application accessing the database are also on multiple Windows
> OSs namely Windows 2000 server, Windows 2003 Server, Windows 2000 and
> Windows XP. The issue is only noticed when the database resides on
> windows 2003 box. The application uses a single connection to call 4
> stored procedures sequentially. The first 3 stored procedures do not
> return any cursor (just parameter info). But the 4th stored proc is
> expected to return a cursor with 0 or more records. When this app is
> executed against a SQL server residing on a 2000 server, it returns a
> rowset with no rows but all the metadata information is available
> (cursor field names).
> But in case of Windows 2003 box, when the stored proc has no records
> to return (empty cursor), the rowset is set to nil. Basically as part
> of the OleDb interface I am calling ICommand
> HRESULT Execute (
> IUnknown *pUnkOuter,
> REFIID riid,
> DBPARAMS *pParams,
> DBROWCOUNT *pcRowsAffected,
> IUnknown **ppRowset);\
> In the 2000 server, the IUnknown is a pointer after the execution, but
> in 2003, the value is nil. Does anyone know if the SQLServer provider
> has been modified to return a nil in case of a empty cursor or is this
> a bug? Also if anyone knows of any work arounds or fixes, I would
> greatly appreciate it if you could share it with me.
It is not really clear to me. Do you get this problem when you connect
to the SQL Server residing on the Windows 2003 box, no matter which
operating system the client is on?
If that is the case, I can't see that MDAC versions has anything to
do with it, but there is something on the server, that is causing the
NULL pointer.
A few more questions:
o If the stored procedure returns data, do you get a pointer in this
case?
o What is the return code of ICommand::Execute?
o What do you pass for REFIID?
o You talk about cursor. Is that a really true server-side cursor, or
is it just a result set that you get back?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
|||Thank you for the response.
Yes, the issue happens when I connect to a SQL server residing on a
Windows 2003 box, regardless of the O/s the app is on (have tried
running the app on Windows 2003 and Windows XP).
o If the stored procedure returns data, do you get a pointer in this
case? - Yes, I do get a pointer when a recordset is present.
o What is the return code of ICommand::Execute? - The return code is
0, which means successful
o What do you pass for REFIID? - IID_IUnknown: TGUID =
'{00000000-0000-0000-C000-000000000046}';
o You talk about cursor. Is that a really true server-side cursor,
or
is it just a result set that you get back? - It is just a
resultset.
Thank you.
Subra.
Erland Sommarskog <esquel@.sommarskog.se> wrote in message news:<Xns9599EFD3E715FYazorman@.127.0.0.1>...
> Subra (subramanyan.ramanathan@.gmail.com) writes:
> It is not really clear to me. Do you get this problem when you connect
> to the SQL Server residing on the Windows 2003 box, no matter which
> operating system the client is on?
> If that is the case, I can't see that MDAC versions has anything to
> do with it, but there is something on the server, that is causing the
> NULL pointer.
> A few more questions:
> o If the stored procedure returns data, do you get a pointer in this
> case?
> o What is the return code of ICommand::Execute?
> o What do you pass for REFIID?
> o You talk about cursor. Is that a really true server-side cursor, or
> is it just a result set that you get back?
|||Subra (subramanyan.ramanathan@.gmail.com) writes:
> Thank you for the response.
> Yes, the issue happens when I connect to a SQL server residing on a
> Windows 2003 box, regardless of the O/s the app is on (have tried
> running the app on Windows 2003 and Windows XP).
> o If the stored procedure returns data, do you get a pointer in this
> case? - Yes, I do get a pointer when a recordset is present.
> o What is the return code of ICommand::Execute? - The return code is
> 0, which means successful
> o What do you pass for REFIID? - IID_IUnknown: TGUID =
> '{00000000-0000-0000-C000-000000000046}';
> o You talk about cursor. Is that a really true server-side cursor,
> or
> is it just a result set that you get back? - It is just a
> resultset.
What strikes me as odd is the use if IID_IUnknown. Normally you would
use IID_IRowset or IID_IMultipleResults. I don't know if this has anything
to do with it.
But since the error is independent of which OS the client is on, I am
more inclined to think that there is a difference between the code
running on the two SQL Servers, or the their configuration. I can't
see that the MDAC version should matter.
Could you post the code for the stored procedure? Preferably take it from
the Win2003 database. Also the C++ code from where you create the
command up to the point of execution helps. There are a few variations
with prepared statements, calling syntax etc. It is difficult to recreate
you scenario, without knowing what you are doing.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
|||Erland,
I managed to figure out the issue just recently. The reason for the
issue is that in the stored proc that had the issue, I am using some
temp tables to return data. Supposedly in the newer version of SQL
Server OLEDB provider (SQLOLEDB) they return a result of each
statement that gets executed in the stored proc. This and the
combination of having temp tables in the stored proc results in some
errors and hence no cursor is returned. So the recommended fix for
this issue is to have the setting "SET NOCOUNT ON". I am attaching a
link to the article on the microsoft website.
http://support.microsoft.com/default...b;en-us;235340
Thank you for your assistance.
Regards,
Subra.
Erland Sommarskog <esquel@.sommarskog.se> wrote in message news:<Xns959CD7F71B5EFYazorman@.127.0.0.1>...
> Subra (subramanyan.ramanathan@.gmail.com) writes:
> What strikes me as odd is the use if IID_IUnknown. Normally you would
> use IID_IRowset or IID_IMultipleResults. I don't know if this has anything
> to do with it.
> But since the error is independent of which OS the client is on, I am
> more inclined to think that there is a difference between the code
> running on the two SQL Servers, or the their configuration. I can't
> see that the MDAC version should matter.
> Could you post the code for the stored procedure? Preferably take it from
> the Win2003 database. Also the C++ code from where you create the
> command up to the point of execution helps. There are a few variations
> with prepared statements, calling syntax etc. It is difficult to recreate
> you scenario, without knowing what you are doing.
|||Subra (subramanyan.ramanathan@.gmail.com) writes:
> I managed to figure out the issue just recently. The reason for the
> issue is that in the stored proc that had the issue, I am using some
> temp tables to return data. Supposedly in the newer version of SQL
> Server OLEDB provider (SQLOLEDB) they return a result of each
> statement that gets executed in the stored proc. This and the
> combination of having temp tables in the stored proc results in some
> errors and hence no cursor is returned. So the recommended fix for
> this issue is to have the setting "SET NOCOUNT ON". I am attaching a
> link to the article on the microsoft website.
> http://support.microsoft.com/default...b;en-us;235340
Glad to hear that you were able to resovle the issue!
There is not really any change in the basic behaviour. By default SQL
Server returns a "rows affected" message for each INSERT, DELETE and UPDATE
statement. With most client libraries you get this as count without a result
set. If your code does not handle this, and only looks for the first result
set, all you get is the first "rows affected" message, but no rowset pointer
or the equivalent.
In many cases, these rowcounts are of little interest, so submitting SET
NOCOUNT ON, kills two birds with two stones: you get the data you are
looking for in the first result set, and you improve performance, since
you reduce network traffic.
My recommendation, though, is to use IMultipleResults and get all result
sets, anyway. This makes the code more robust, not the least with regards
to catching errors and PRINT messages.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

OLEDB driver omits SP return value

Hi,

I have a problem with some ATL7/OLEDB code. I'm trying to execute stored procedures from my application. I do get a result set back, but I never get a correct return value back. I've been going through MSDN articles as well as other articles on the web, and I just cannot see what I'm doing wrong!

I have this piece of ATL code:
<pre>
// code generated on den 6 juni 2002, 10:56

[
db_command(L"{ ? = CALL dbo.MyProc(?) }")
]
class CMyProc
{
public:
[ db_column(1, status=m_dwIdStatus, length=m_dwIdLength) ] LONG m_Id;
/* and so on - 7 columns total */

[ db_param(1, DBPARAMIO_OUTPUT) ] LONG m_RETURN_VALUE;
[ db_param(2, DBPARAMIO_INPUT) ] LONG m_id;

void GetRowsetProperties(CDBPropSet* pPropSet)
{
pPropSet->AddProperty(DBPROP_CANFETCHBACKWARDS, true, DBPROPOPTIONS_OPTIONAL);
pPropSet->AddProperty(DBPROP_CANSCROLLBACKWARDS, true, DBPROPOPTIONS_OPTIONAL);
}
};

</pre>

When I use this code I do:
<pre>
CSession dbsession;
CDataSource dbsource;
CDBPropSet dbinit(DBPROPSET_DBINIT);
/* fill dbinit with connection parameters */
/* HRESULTs not checked for brevity*/
dbsource.Open(_T("SQLOLEDB.1"), &dbinit);
dbsession.Open(dbsource);

CMyProc proc;
proc.m_id = 1;
proc.Open(dbsession);

TRACE("Return value is %d\n", proc.m_RETURN_VALUE);

/* Take care of result set - which exists and is valid! */
</pre>

The return value is <tt>-858993460</tt> which is <tt>0xcccccccc</tt>. In Visual C++ this value is used as an "uninitialized" stack value during debug. It seems as if ATL never bothers to update my return value parameters! I even made a little experiment with an extra output parameter - same thing there.

I'm using Visual C++ .NET and the SQL 2000 OLEDB provider (SP2). I've also tried this without attributed programming in both Visual C++ .NET and Visual C++ 6.

Does anybody have a clue what is going on??Is the stored procedure using set nocount on ? If not, put it in the stored procedure.

Good luck.|||Thanks for replying!

I tried with and without nocount and had no success.

I tried something else the other day though; I generated a non-attributed CCommand-class using CMultipleResults as template parameter. Then I could get all out parameters by calling GetNextResult() on the command object.

So my question is now; how do I make the attribute-injector generate a CCommand class for me using CMultipleResults?

Monday, March 19, 2012

OleDB Connection to Excel

Hi,

My application connects to excel files.
I am using this code:



dc = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + fileName + ";" +
"Extended Properties=\"Excel 8.0;HDR=YES;\"");

It works fine on Excel 2000 on all computers. Also it works on some computers with Excel 2002/XP, but on some computers with Excel 2002/XP it doesn't work.

How can I solve it?

Thank's
AlexeiHi,
I used above code sample for my program. but i did not worked.can u help me. I want to do ,take excel information to one record set or data set.I can't understand how to do it.I send u my connection coding.please check it send me wht is the correct syntax or correct code and tell me wht is the componts want. this program using the .net
following has my codes:

MyConnection = New OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=D:\Oven Sheet (Track)\Data For Symix_23082005-Tracks.xls;Extended Properties=\Excel 8.0")

|||Are you sure you have the right version of Jet on the machine? Check this by right clicking on the desktop and create a new text file, call it demo.udl. This is a datalink file. If you double click on the file it should show you a list of OLE DB Providers, check that Jet 4.0 is installed.

If it is installed then try changing \Excel 8.0 to plain Excel 8.0

Monday, March 12, 2012

OLE-DB ?

Hai,

I have developed an SDI application in VC++ 6.0 version to connect remote MSSQL server through "OLE-DB" in Windows 2000 Proffesional . Through the IDE,i have selected "OLE-DB provider for ODBC Driver ".

I have used two threads, one for computation and another for accessing database. In the database thread, for every 2 second the rowset is opened, updated and closed. In the Second thread, for every 10 millisecond data is computed.

My Code looks like,

xxView.cpp

Database Thread()
{

for(;;)
{
Waitforsingleobject(x,2000) // Two second event
{
m_pSet->Open();

// Update data
m_pSet->SetData();
m_pSet->Close();
}
}
return 0;
}

xxapp.cpp

Comput Thread()
{

for(;;)
{
Waitforsingleobject(x,8) // event
{
//Compute data

}
}

return 0;
}

The application is in debug mode, well application work in development PC. When i deploy the application in a Client PC for testing with debug mode, the application works well for first few hours, then the application lags. The computation thread is delayed in seconds.

In the client PC i have installed MDAC 2.8.

* What could be the reason? Is it due to the sharing resources of "Msvcrt.dll".

* Also another application uses the same database.

* Do i have to statically link the MFC Dll?

Thanks in Advance.

There can be varieties of reasons such as memory leak, network condition changes, antivirus softwares and many others. You can profile your code (by adding trace/log point around APIs and to narrow down the issue.

Thanks,

Friday, March 9, 2012

OLE DB Source and OLE DB Destination components: how to do without the datasourc

Hello all,

I'm implementing an application that builds SSIS package. I've faced the problem I don't know what to do about it.

In a simple case, I build a dataflow which has OLE DB Source and OLE DB Destination component. The problem is, that at the moment I build the dataflow I don't have source and target databases, i.e. datasources. A source database is accessed and a target database is created later, and after that the package is run.

In this situation connection strings for source and destination sources are populated via variables, but what to do about columns in the source/destination which at the moment the package is created cannot be retrieved from data sources. When designing, they are taken from respective datasources, custom columns, not from a datasource, cannot be added.

I don't know how to populate OLE DB Source and OLE DB Destination components with columns, not from datasources, but with ones from not existing databases yet, which will exist when the package is executed. In what way can I do that?

Thanks in advance,

sash pSorry if my question is easy, but I'm so new to SSIS programming. I've just looked around and noticed "OpenRowset Using FastLoad From Variable" option for the OLE DB Source/Destination. Of course at the design time I need to specify datasources but I can specify a table name in a variable. At a run time, when programmatically building a package, I only need variables for connection strings and source/destination tables. And then that will work. Correct me please if I'm wrong.

sash p