Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Thursday, March 29, 2012

Configure data source insertion into SQL Server 2005 database - Express editions

I am attempting to insert information from Visual Web Developer 2005 using either the Gridview or Datalist controls into a SQL Server 2005 database and get stuck when defining the custom statement.

When I enter the text within the insert tab, the <next> button remains greyed out, preventing me from continuing to the next page.

If I copy the same text into the select tab, then I can continue with the wizard, however this raises other problems which may or may not be related (multiple insertions of the data into the SQL Server database table - possibly due to postback functions). I would rather use insert to confirm that my second problem is not because I am using the wrong option.

My question is:

Should I be able to use the insert function within VWD express or is this only available within the standard/pro editions?

Are you using SqlDataSource as the DataSource fo GridView/DataList? I tried that and I can edit customized INSERT command. Can you open QueryBuilder when you enter INSERT command?

|||

I am using SqlDataSource as the datasource as well as a valid connection string to my SQL Server Database.

I launched query builder to construct the sql command for insert. It brings up the appropriate table and columns and I have tried using both parameters and then free text responses with the same result.

If I copy the complete insert command (as constructed from query builder) and paste it into the select tab, then I am able to complete the wizard and my table is populated (albeit with multiple rows).

This implies that the sql statement is valid, however I would have thought that even a simple insert query - insert into table1 values("xxx") - would allow me to progress through the SqlDatasource wizard without any difficulty.

Sadly, I am unable to attach a screenshot which would make the visualisation of the problem that much easier.

To re-iterate my problem, I only get so far within the configure data source wizard - click a tab to create a SQL statement for that operation - <INSERT-TAB>, "sql_statement" before hitting a brick wall as both the next and finish buttons are greyed out.

I would appreciate any assistance you can provide on this matter.

Paul

Tuesday, March 27, 2012

Configuration Help

I am running 2005 reporting services and 2005 visual studio. I have a
c# .net web application located in the default web directory in IIS
that uses forms authentication, but that authentication is to active
directory using an ldap call inside the code. We set it up that way so
the user can log in to a normal page instead of the windows pop-up
login. I have reporting services running inside the web site directory.
It is setup to use windows authentication. I have the user login into
the web site and then when they go to run a report a windows login box
appears and they have to login again. Does anyone know how I can
authenticate to reporting services in the background so the user does
not see the windows pop-up login.
Thanks in advance,
JasonWrite a FormsAuthentication extension to MSRS.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/html/ufairs.asp
When you app hits LDAP, you can also authenticate against MSRS and grab
the auth cookies for MSRS. Your other options is to hijacks the
ASP.NET pipeline when a user requests an MSRS report and perform the
auth on demand.
Andy Pottersqlsql

Configuration for SQL 2000

Hi,

What configuration steps should I do to enable my .NET web application to access my SQL 2000 database? I have SQL Server 2000 SP3, SQL 2005 Express, SQL 2005 and VS 2005 installed on the same machine. Is it anything to do with the NT Authority\Network Service or ASPNET account that I need to allow access to or what? Kinda lost here... been banging my server for the past week.

Cheers!

There are several options. Do you want to run the SQL Server in Mixed Mode ? DO you want to use impersonation ? DO you want to impersoante the user at the SQL Server ?

-Jens Suessmeyer.


|||

That is also my next question. What I would like is for annonymous access to view the data taken from the database. Only authorized personnel can log in through Forms Authentication to Insert, Update or Delete the database.

I believe this is a simple implementation but I can't seem to get the configuration right. The database works if I put it as a local database but that defeats the purpose of the implementation.

I got this error which I believe is very common

What can I set in IIS 6.0, Compiter Management and SQL 2000?:

Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration>

|||

Anyway after some tweaking here and there, I managed to get it to work properly. Added NT Authority\Local Service account to SQL 2000 User Login, which will categorize it as the public grp. After that checking the tables this group can operate Select instruction on.

This is probably not the conventional way, so I would like to know what the generic workable implementation should be (otherwise called the industrial standard).

Cheers!

Configuration file for reporting server project

Hi!
Is it somehow possible to create a configuration file for a reporting server
project. Something similar like the web.config or app.config file in .NET
applications?
What I wanna do is to store the link of a picture file. I don't want to
hard-code that in every report.
Are there any other options than storing this link in a config file?
Cheers, RogerOn Jul 17, 8:37 am, "Roger Frei" <s...@.hotmail.com> wrote:
> Hi!
> Is it somehow possible to create a configuration file for a reporting server
> project. Something similar like the web.config or app.config file in .NET
> applications?
> What I wanna do is to store the link of a picture file. I don't want to
> hard-code that in every report.
> Are there any other options than storing this link in a config file?
> Cheers, Roger
What you could try doing is include a link to a picture file in a
report and then check the XML structure of the underlying RDL file in
a text editor (Notepad, Wordpad, etc). Then change the path in the RDL
file via a custom application that creates the RDL file on the fly.
This might be a bit tedious but it may be the only option.
Regards,
Enrique Martinez
Sr. Software Consultant|||On Jul 17, 2:37 pm, "Roger Frei" <s...@.hotmail.com> wrote:
> Hi!
> Is it somehow possible to create a configuration file for a reporting server
> project. Something similar like the web.config or app.config file in .NET
> applications?
> What I wanna do is to store the link of a picture file. I don't want to
> hard-code that in every report.
> Are there any other options than storing this link in a config file?
> Cheers, Roger
Roger,
Add the picture file to your report project - deploy and hide - no ?

Sunday, March 25, 2012

Config Help for Server2003/sql2000/iis6 Reporting Services

Newbie alert. Need some configuration help please. Have web server with 3
websites on box above with same ip using host headers (well-established sites
working fine). Installed reporting services, went to one website and created
virtual directories with IIS to same folder/name as items under Default Web
Site. Authentication is set to IUSR_svrname, Integrated Windows on website
and virtual directories.
Created a basic report & deployed to http://serverName/reportServer. I can
view report by url similar
to:http://serverName/Reportserver?%2fFolderName%2freportName&rs:Command=Render Data connection and report retrieval is fine.
But, I need folks to be able to enter the www.domainname.com type of url and
that gives me a HTTP Error 403.8 - Forbidden: DNS name of the client is
rejected. As soon as I remove the report services part of the url, site
pops up fine. And, if possible, I'd like to be able to use more than one of
my domains, just referencing the virtual directory in IIS for each site.
Also, I cannot get to the http://serverName/Reports/Pages/Folder.aspx to set
roles and permissions because it only sees me as IUSR and I can't "see"
anything under that role. Even though I'm a domain administrator, believe
it's seeing me as IUSR.
Tried a few things but may be making it worse. Thanks for any advice-would
really like to be able to use this tool, but can't at this point.Update - think I'm really close, but still need help. Uninstalled,
reinstalled RS. Deployed sample. Added <ReportServerExternalURL>
http://www.domainname.org/Reports </ReportServerExternalURL> to
rswebapplication.config Deployed.
Created new role for IUSR_MachineName and gave it browse capabilities on
home folder.
Added virtual directory is IIS under web site above for Reports, with
documents of home.aspx and enable IUSR in IIS for directory. (Deployment is
still okay.) If I view Reports via machinename, site settings are there.
Browse to folder, click on report, the folder pops up again. Report will not
generate. If I view via www, site settings are not there (good, good).
Report does the same thing - popping up another folder view but not
generating.
Added virtual directory is IIS under web site above for ReportServer, with
document sof default.htm, default.asp, index.htm, iisstart.htm, default.aspx.
Same thing happens again.
Think I'm very close. Anybody?|||Finally got a reply on another forum so thought I'd pass it along. Even
though the documentation explicitly says:
"To access a report server on the Internet, you must add a
ReportServerExternalURL configuration setting that specifies the fully
qualified domain name of the report server. The external client uses this
value to access a report server. In this scenario, the browser that is
hosting Report Manager must send a fully qualified domain name when making
requests on behalf of Report Manager to the report server. The following
example illustrates the syntax for ReportServerExternalURL:
<ReportServerExternalURL> reports.adventure-works.com
</ReportServerExternalURL>"
When I replaced the UI with the following, things started rendering properly.
<UI>
<ReportServerVirtualDirectory>/ReportServer</ReportServerVirtualDirectory>
</UI>
Hope it helps out someone else.

Config error

I get this error. Does any body came across this and found some solution?

Compiler Error Message: CS0433: The type 'Microsoft.Web.UI.ScriptManager' exists in both 'c:\WINDOWS.000\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\websites_hrdbms\3acda2bb\a63d28c5\assembly\dl3\32deaeca\005606e1_3759c601\Microsoft.Web.Atlas.DLL' and 'c:\WINDOWS.000\assembly\GAC_MSIL\Microsoft.Web.Extensions\1.0.61025.0__31bf3856ad364e35\Microsoft.Web.Extensions.dll'

I have created the application with ATLAS July CTP . currently upgraded to ASP.NET AJAX BETA 1. I face the above problem

Ramanan wrote:

I get this error. Does any body came across this and found some solution?

Compiler Error Message: CS0433: The type 'Microsoft.Web.UI.ScriptManager' exists in both 'c:\WINDOWS.000\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\websites_hrdbms\3acda2bb\a63d28c5\assembly\dl3\32deaeca\005606e1_3759c601\Microsoft.Web.Atlas.DLL' and 'c:\WINDOWS.000\assembly\GAC_MSIL\Microsoft.Web.Extensions\1.0.61025.0__31bf3856ad364e35\Microsoft.Web.Extensions.dll'

I have created the application with ATLAS July CTP . currently upgraded to ASP.NET AJAX BETA 1. I face the above problem

Wrong forum.

Thursday, March 22, 2012

Confguring Report Builder

--Hello All ,
I am having a problem generating data models with SQL Reporting services
2005 from the web .I installed and configured 2005 Reporting services ,
created few reports and gave access to the users to view the reports from the
browser .Everything goes well till this point . But I don't see the "Generate
Model" button to generate a model from my current Data Source and use it in
the Report Builder feature from the web.I am trying to set this thing right
as it gives the end users to build their own reports from the web using
Report Builder.
Does it have to do with the security feature of Reporting Services ? If so
how can I configure the accounts ? [ I am using windows 2003 server with
IIS 6.0 and SQL Server 2005 CTP ]
Any help is highly appreciated .
thank you
K.This is controlled through the "Manage models" role, similar to all the
other RS security roles (e.g. "View reports", "Manage reports", etc.). Here
is a starting point for managing role level security in RS 2005:
http://msdn2.microsoft.com/ms228284(en-US,SQL.90).aspx
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"Kallis" <Kallis@.discussions.microsoft.com> wrote in message
news:B9D96877-14FC-44FC-A99F-B2E63566E501@.microsoft.com...
> --Hello All ,
> I am having a problem generating data models with SQL Reporting services
> 2005 from the web .I installed and configured 2005 Reporting services ,
> created few reports and gave access to the users to view the reports from
> the
> browser .Everything goes well till this point . But I don't see the
> "Generate
> Model" button to generate a model from my current Data Source and use it
> in
> the Report Builder feature from the web.I am trying to set this thing
> right
> as it gives the end users to build their own reports from the web using
> Report Builder.
> Does it have to do with the security feature of Reporting Services ? If so
> how can I configure the accounts ? [ I am using windows 2003 server with
> IIS 6.0 and SQL Server 2005 CTP ]
> Any help is highly appreciated .
> thank you
> K.|||Robert,
Thank You for responding to my question . I gave the 'Content Manager' role
all the permissions inside Reporting server roles . From the browser , I
assigned the 'Content Manager' role to a group { local to the server where
IIS is installed}.Even then I am not able to view the 'Generate Models'
button besides 'Apply',Move & 'Delete' buttons . In addition to the above ,
when I run a report from report builder I get he following msg 'An attempt
has been made to use a data extension 'OLEDB-MD' that is not registered for
this report server'. How can I overcome this issue ?
Thanks for helping !!
-K
--
K
"Robert Bruckner [MSFT]" wrote:
> This is controlled through the "Manage models" role, similar to all the
> other RS security roles (e.g. "View reports", "Manage reports", etc.). Here
> is a starting point for managing role level security in RS 2005:
> http://msdn2.microsoft.com/ms228284(en-US,SQL.90).aspx
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Kallis" <Kallis@.discussions.microsoft.com> wrote in message
> news:B9D96877-14FC-44FC-A99F-B2E63566E501@.microsoft.com...
> >
> > --Hello All ,
> >
> > I am having a problem generating data models with SQL Reporting services
> > 2005 from the web .I installed and configured 2005 Reporting services ,
> > created few reports and gave access to the users to view the reports from
> > the
> > browser .Everything goes well till this point . But I don't see the
> > "Generate
> > Model" button to generate a model from my current Data Source and use it
> > in
> > the Report Builder feature from the web.I am trying to set this thing
> > right
> > as it gives the end users to build their own reports from the web using
> > Report Builder.
> >
> > Does it have to do with the security feature of Reporting Services ? If so
> > how can I configure the accounts ? [ I am using windows 2003 server with
> > IIS 6.0 and SQL Server 2005 CTP ]
> >
> > Any help is highly appreciated .
> >
> > thank you
> >
> > K.
>
>

Conecting linked servers using VB6.0

I have an SQL web site linked to may SQL Server. I am using the IP address t
o
do this.
Then I tried to make an ODBC to link VB6.0 to update some tables in the
linked server, but it always give me an error message saying that the server
doesn't exist or i do not have permitions. I am using the same permitions I
used to create the linked server, so i do not know what else i can do.
can any body help me?Why aren't you simply connecting directly to the server instead of through S
QL
Server's linked server?
If you want to connect to a single source but have data from multiple source
s,
then create stored proces and views that query the linked server. Granted, t
his
will be slower than querying the linked server directly.
HTH
Thomas
"Lina Manjarres" <LinaManjarres@.discussions.microsoft.com> wrote in message
news:0C040BE5-A598-489C-9EC9-F681841EE641@.microsoft.com...
>I have an SQL web site linked to may SQL Server. I am using the IP address
to
> do this.
> Then I tried to make an ODBC to link VB6.0 to update some tables in the
> linked server, but it always give me an error message saying that the serv
er
> doesn't exist or i do not have permitions. I am using the same permitions
I
> used to create the linked server, so i do not know what else i can do.
> can any body help me?|||Of course, why didn't I think about it before?
Thanks a lot!
"Thomas" wrote:

> Why aren't you simply connecting directly to the server instead of through
SQL
> Server's linked server?
> If you want to connect to a single source but have data from multiple sour
ces,
> then create stored proces and views that query the linked server. Granted,
this
> will be slower than querying the linked server directly.
>
> HTH
>
> Thomas
>
> "Lina Manjarres" <LinaManjarres@.discussions.microsoft.com> wrote in messag
e
> news:0C040BE5-A598-489C-9EC9-F681841EE641@.microsoft.com...
>
>sqlsql

Wednesday, March 7, 2012

Conditional Formatting - Export

Using the web viewer control in VS 2005, is there a way to conditionally format items for export only?

For example, user runs a report which gets displayed in the viewer. The report contains small images and or decorated text for links to additional reports. If user selects pdf from the export dropdown list and clicks export, I would like hide the images in the pdf and or format the decorated text differently.

If the answer is no, is it due to the report already being in its intermediate state?

The answer to your first question is no. One way of getting close to the desired behavior is to either use different report definitions or use a report parameter to determine if images should be shown etc.

The answer to the second question is yes. When you export the report to PDF, it will just re-render the report from the already processed (and output-format independent) intermediate format.

-- Robert

Saturday, February 25, 2012

Conditional fields based on export type

I need to be able to suppress the printing of a particular value when exporting, but not when displaying on a web viewer on-line. I can place an IIF() condition around the field to do this, but do not know how to obtain a parameter/value/function which would recognize that the viewer has selected an export (To .PDF for example).

I would prefer there be a direct parameter I can read from the RDL language, however recognizing the selection while setting up the viewer to be displayed in the code-behind and setting an external parameter is also an option.

Any help would be appreciated.

Jerry

Hi Jerry

I do not know if it is possible for PDF. I know you can limit what fields are exported for CSV and XML.
To do this open the properties box on the field you do not wish to export and click on the data output tab.
Then change the Output radio box from 'Auto' to 'No'

Cheers
Mark
|||

What I really need is the ability to disable the creation of the hyperlink when the report is exported.

I see now that the pageload method is not even fired at the time the choice to export is made. Therefore I will need to determine what program is being run upon this selection and be able to set the parameters of that program. As I see now this just may not exist.

Friday, February 17, 2012

concurrent connection limits

I'm new using SQL 2005 Express

I'm planning to use SQL Server Express 2005 for a asp net web application for a video rental store.

Is there a concurrent user conection limit that I should care?

TIA

Gerardo

You can find more information here.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

Tuesday, February 14, 2012

Concurrency Help

I need a little help figuring out how to design my database/web
services for a bidding system. I'm not sure how to solve the problem
of concurrency. I'll give an analogous example of what the system is
supposed to do. In a nutshell, there are 10,000 computers with 10 gigs
of hard drive space each, which are sold to the highest bidder in 1
gig chunks. The bidder simply tells me how much they are willing to
spend and what state or country the computer should be located in. The
system should fill their order if they have the highest bid on a gig
with their criteria. How the hell do I assign those chunks to the
highest bidder efficiently. The problem with concurrency would be when
two or more people are getting data and submitting data at the same
time. If its not done synchronously or isn't thread safe, then the
amount of available space may be incorrectly read or written, for
example.
Is there a standard way to solve this type of database/web service
design problem?David
http://dimantdatabasesolutions.blogspot.com/2007/04/whats-version-of-sql-server.html
SQL Server 2005 provides a new feature called SQL Service Broker
Link from BOL
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlmsg9/html/72caf5ae-4f7b-4e82-90f6-066560476632.htm
<Davidhere40@.gmail.com> wrote in message
news:1180226682.660613.122090@.h2g2000hsg.googlegroups.com...
>I need a little help figuring out how to design my database/web
> services for a bidding system. I'm not sure how to solve the problem
> of concurrency. I'll give an analogous example of what the system is
> supposed to do. In a nutshell, there are 10,000 computers with 10 gigs
> of hard drive space each, which are sold to the highest bidder in 1
> gig chunks. The bidder simply tells me how much they are willing to
> spend and what state or country the computer should be located in. The
> system should fill their order if they have the highest bid on a gig
> with their criteria. How the hell do I assign those chunks to the
> highest bidder efficiently. The problem with concurrency would be when
> two or more people are getting data and submitting data at the same
> time. If its not done synchronously or isn't thread safe, then the
> amount of available space may be incorrectly read or written, for
> example.
> Is there a standard way to solve this type of database/web service
> design problem?
>|||On May 27, 2:56 am, "Uri Dimant" <u...@.iscar.co.il> wrote:
> Davidhttp://dimantdatabasesolutions.blogspot.com/2007/04/whats-version-of-...
> SQL Server 2005 provides a new feature called SQL Service Broker
> Link from BOL
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlmsg9/html/72caf5ae-4f7b-4e82-90f6-066560476632.htm
> <Davidher...@.gmail.com> wrote in message
> news:1180226682.660613.122090@.h2g2000hsg.googlegroups.com...
> >I need a little help figuring out how to design my database/web
> > services for a bidding system. I'm not sure how to solve the problem
> > of concurrency. I'll give an analogous example of what the system is
> > supposed to do. In a nutshell, there are 10,000 computers with 10 gigs
> > of hard drive space each, which are sold to the highest bidder in 1
> > gig chunks. The bidder simply tells me how much they are willing to
> > spend and what state or country the computer should be located in. The
> > system should fill their order if they have the highest bid on a gig
> > with their criteria. How the hell do I assign those chunks to the
> > highest bidder efficiently. The problem with concurrency would be when
> > two or more people are getting data and submitting data at the same
> > time. If its not done synchronously or isn't thread safe, then the
> > amount of available space may be incorrectly read or written, for
> > example.
> > Is there a standard way to solve this type of database/web service
> > design problem?
Thank you very much! I really needed that.
Dave|||On May 27, 7:27 pm, Davidher...@.gmail.com wrote:
> On May 27, 2:56 am, "Uri Dimant" <u...@.iscar.co.il> wrote:
>
> > Davidhttp://dimantdatabasesolutions.blogspot.com/2007/04/whats-version-of-...
> > SQL Server 2005 provides a new feature called SQL Service Broker
> > Link from BOL
> > ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlmsg9/html/72caf5ae-4f7b-4e82-90f6-066560476632.htm
> > <Davidher...@.gmail.com> wrote in message
> >news:1180226682.660613.122090@.h2g2000hsg.googlegroups.com...
> > >I need a little help figuring out how to design my database/web
> > > services for a bidding system. I'm not sure how to solve the problem
> > > of concurrency. I'll give an analogous example of what the system is
> > > supposed to do. In a nutshell, there are 10,000 computers with 10 gigs
> > > of hard drive space each, which are sold to the highest bidder in 1
> > > gig chunks. The bidder simply tells me how much they are willing to
> > > spend and what state or country the computer should be located in. The
> > > system should fill their order if they have the highest bid on a gig
> > > with their criteria. How the hell do I assign those chunks to the
> > > highest bidder efficiently. The problem with concurrency would be when
> > > two or more people are getting data and submitting data at the same
> > > time. If its not done synchronously or isn't thread safe, then the
> > > amount of available space may be incorrectly read or written, for
> > > example.
> > > Is there a standard way to solve this type of database/web service
> > > design problem?
> Thank you very much! I really needed that.
> Dave
Turns out, I think the real answer to this question was to use
timestamps. I find out on my own. SQL broker is a pain to setup and
limits you to SQL server. I don't think it's necessary in my
situation. Especially because using timestamps allows you to do as
much work simultaneously as possible and if a different timestamp is
encounted for some data, you can simply reload the data and then try
again.
Dave

Concurrency Control

Hi! I'm building a web application with ASP.NET, and using MS SQL 2000 for my database server.

How should I do to guarantee the integrity of the data in spite of the concurrent access? Meaning... how can I make sure that more than 1 user can update 1 table at the same time, while no error will occur? Do I need to add some codes at my aspx file? Or do I need to do something to my database? Or do I not have to worry about it?

Thank you.

Well, from a database standpoint -- SQL server already has the abilityto deal with concurrent users, no modifications are necessary. Locksand other mechanisms make sure data updates don't interfere with oneanother. There are cirumstances where concurrent data access can causeproblems (deadlocks for instance), but these circumstances are rare.
So I guess the short answer is don't worry about it.
Jason

Concurrency Control

Hi! I'm building a web application with ASP.NET, and using MS SQL 2000 for m
y
database server.
How should I do to guarantee the integrity of the data in spite of the
concurrent access? Meaning... how can I make sure that more than 1 user can
update 1 table at the same time, while no error will occur? Do I need to add
some codes at my aspx file? Or do I need to do something to my database? Or
do I not have to worry about it?
Thank you.The easiest way is to use a rowversion (timestamp) type column. Look it up
in the books online for most of the details, but simply put, it is a
automatically maintained value that will change everytime your rows in your
database change. Then, as part of every update and delete of rows you have
cached, you can compare these values in the where clause and if they don't
match you knwo someone else has modified the row.
Then you just fetch the row back to the client and let them know what
changed.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"wrytat" <wrytat@.discussions.microsoft.com> wrote in message
news:12D9DA82-8D0B-451E-881F-6AAEE852DC14@.microsoft.com...
> Hi! I'm building a web application with ASP.NET, and using MS SQL 2000 for
> my
> database server.
> How should I do to guarantee the integrity of the data in spite of the
> concurrent access? Meaning... how can I make sure that more than 1 user
> can
> update 1 table at the same time, while no error will occur? Do I need to
> add
> some codes at my aspx file? Or do I need to do something to my database?
> Or
> do I not have to worry about it?
> Thank you.|||That all depends on what is actually needed. You have two viable choices in
my opinion:
1. Last write wins
2. First write wins
In the first scenario, the data from the person that makes the last write
call is the data that sticks. This is by far the easiest, but it has the
obvious downside of not informing the first user who just wrote their data
that their write was superceded.
In the second scenario, the data from the first person that writes to a row
sticks and an error is thrown for all other users. This is far more
complicated as you have to decide how to handle concurrency errors. Do you
let users choose whether to overwrite the data? Do you simply overwrite it?
Do you throw an error and force the user to re-enter their information? If
on a multi-row write, only of subset of writes fails, do you rollback all
writes?
As you can see, the second scenario is far more complicated to handle.
However, if you want to use the second scenario, then you need a way of
determining whether the row has changed since you last read the data. That
can be done in a couple of ways:
1. Timestamp. You add a timestamp column for every table that participates
in the First Write Wins scenario. For every write, you ask whether the
existing timestamp on the record is the same as the one you have when you
read the data. If they are different, you have a concurrency error,
otherwise write the data.
2. Other row version data type. Same solution as #1, except you use
something other than an actual Timestamp field. I have used Guids in the
past successfully.
3. You compare all fields you are trying to update with the values you had
on initial read. In order to really do this, you need to use dynamic SQL. It
is simply too cumbersome to try to handle with stored procs. The .NET
SqlDataAdapter does a passable job at this. There are also Object Relation
Mappers that will do this work for you or you can roll your own. Beyond not
being able to use stored procs, the other downside to this approach is that
the SQL statements can very long very fast, especially if some of the fields
are Text or Image.
4. Checksum. SQL has a checksum function that XOR the data in all the
columns to produce a quasi-unique number representing the contents of the
row. The catch is that SQL's checksum function does not account for Text or
Image columns.
IMO, you really need a very strong justification to going with First Write
Wins. The additional complexity added is significant and must be justified
by a high expected rate of collision and the absolute need for
user-consistency on all writes.
HTH,
Thomas
"wrytat" <wrytat@.discussions.microsoft.com> wrote in message
news:12D9DA82-8D0B-451E-881F-6AAEE852DC14@.microsoft.com...
> Hi! I'm building a web application with ASP.NET, and using MS SQL 2000 for
> my
> database server.
> How should I do to guarantee the integrity of the data in spite of the
> concurrent access? Meaning... how can I make sure that more than 1 user
> can
> update 1 table at the same time, while no error will occur? Do I need to
> add
> some codes at my aspx file? Or do I need to do something to my database?
> Or
> do I not have to worry about it?
> Thank you.|||in ado.net the concept of pessimistic locking is a bit difficult.
basically, ado.net only directly supports optimistic locking.
you'll need to read up on that in a good ado.net book.
sql server has concept of isolation level that you will likely want to read
up on. You can modify the Isolation level via ADO.NET via the sqlConnection
object.
Not to be taken lightly as High concurrency will yield low Consistency and
High consistency will yield low concurrency.
need to know what your application is doing and how tolerant it can be in
regards to dirty reads, etc.
study up. Also Load Test and Performance test Early and Often.
Greg Jackson
PDX, Oregon|||Thank you all of you. I've also read this article
(http://msdn.microsoft.com/library/d...ncychecking.asp) and learned a lot from it.
Then say if by default, I select the Optimistic Concurrency option in the
DataAdapter Configuration Wizard of the Visual Studio to handle Concurrency
Control. Do I still need to add a datetimestamp column to the database table
and compare the value of that column every time I update the table?
And must I also include the comparison of this columns for insert and delete
command as well? I guess the answer is no?
Anyway, someone told me that using SQL 2000 already provides the concurrency
control by default, such that even without ADO.NET, the amount of research o
n
concurrency control in SQL 2000 gurantees data integrity. I don't really kno
w
how true it is.
"pdxJaxon" wrote:

> in ado.net the concept of pessimistic locking is a bit difficult.
> basically, ado.net only directly supports optimistic locking.
> you'll need to read up on that in a good ado.net book.
> sql server has concept of isolation level that you will likely want to rea
d
> up on. You can modify the Isolation level via ADO.NET via the sqlConnectio
n
> object.
> Not to be taken lightly as High concurrency will yield low Consistency and
> High consistency will yield low concurrency.
> need to know what your application is doing and how tolerant it can be in
> regards to dirty reads, etc.
> study up. Also Load Test and Performance test Early and Often.
>
> Greg Jackson
> PDX, Oregon
>
>|||> Do I still need to add a datetimestamp column to the database table
> and compare the value of that column every time I update the table?
No, ADO.NET caches the values of *all* rows and compares the values against
*all* these rows. As far
as I can understand, you can customize this behavior.

> And must I also include the comparison of this columns for insert and dele
te
> command as well? I guess the answer is no?
No.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"wrytat" <wrytat@.discussions.microsoft.com> wrote in message
news:00E5B1E6-97E5-4997-8F7A-BF17E1641332@.microsoft.com...
> Thank you all of you. I've also read this article
> (http://msdn.microsoft.com/library/d...kin
g.asp)
> and learned a lot from it.
> Then say if by default, I select the Optimistic Concurrency option in the
> DataAdapter Configuration Wizard of the Visual Studio to handle Concurrenc
y
> Control. Do I still need to add a datetimestamp column to the database tab
le
> and compare the value of that column every time I update the table?
> And must I also include the comparison of this columns for insert and dele
te
> command as well? I guess the answer is no?
> Anyway, someone told me that using SQL 2000 already provides the concurren
cy
> control by default, such that even without ADO.NET, the amount of research
on
> concurrency control in SQL 2000 gurantees data integrity. I don't really k
now
> how true it is.
> "pdxJaxon" wrote:
>|||On Wed, 6 Apr 2005 20:23:15 -0700, Thomas wrote:
(snip)
>2. Other row version data type. Same solution as #1, except you use
>something other than an actual Timestamp field. I have used Guids in the
>past successfully.
Hi Thomas,
Why on earth would you do that?
A timestamp (aka rowversion) column takes 8 bytes, a uniqueidentifier
takes 16 bytes.
A timestamp column is changed automatically each time a row is inserted
or updated, a uniqueidentifier column is changed only when you
explicitly assign it a new value - so if you forget to, you'll miss the
change.
The timestamp datatype is designed explicitly for this goal, the
uniqueidentifier datatype is designed to be used as a surrogate key.
What is the advantage of using uniqueidentifier for concurrency control?

>4. Checksum. SQL has a checksum function that XOR the data in all the
>columns to produce a quasi-unique number representing the contents of the
>row. The catch is that SQL's checksum function does not account for Text or
>Image columns.
And another catch is that not all changes in the data result in a
different checksum. A different checksum guarantees changes, but an
unchanged checksum doesn't guarantee that the data is unchanged.
SELECT CHECKSUM('a'), CHECKSUM ('aaaaaaaaaaaaaaaaa')

>IMO, you really need a very strong justification to going with First Write
>Wins. The additional complexity added is significant and must be justified
>by a high expected rate of collision and the absolute need for
>user-consistency on all writes.
I couldn't disagree more. The risk of updates being overwritten without
anyone ever noticing is enough justification to take whatever steps are
necessary to prevent this in any serious business.
If you don't want the extra complexity, you should consider pessimistic
locking: get an exclusive rowlock when reading the data, keep the lock
as long as the data is displayed on the users' screen and only release
the lock after either the update is made or the user has decided to quit
the screen without saving changes. This will impact concurrency, but if
you expect very few collisions, it won't be a big deal. If you expect
lots of collisions, go for optimistic locking.
Never use Last Write Wins in any serious multiuser business application.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||On Wed, 6 Apr 2005 23:01:01 -0700, wrytat wrote:

>And must I also include the comparison of this columns for insert and delet
e
>command as well? I guess the answer is no?
Hi wrytat,
I have to disagree with Tibor's answer. You don't need it for inserts
(it's new data, so it can't be already locked), but you probably do need
it for deletes.
Example scenario: I start the application and show customer #123 on my
screen. You start the application and show the same customer. You see
that the information is outdated, find some new information in your
files and you make all changes to reflect the new status.Then you save
your data. Meanwhile, I see that this customre is outdated and I decide
that this old information might just as well be deleted. I hit delete.
The program will then happily delete the new information you just
entered for customer #123.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||> (snip)
<snip>
> What is the advantage of using uniqueidentifier for
> concurrency control?
The primary reason is that the calling code can generate the
new Id. It doesn't require an extra round trip to get the
updated Timestamp. The second reason is that mickeysoft has
already admitted that they are changing the Timestamp column
to be more inline with ANSI standards. Translation: It's
changing and I haven't the foggiest idea how compatitbility
will work. Lastly, and this was far more true in the past,
various development technologies did not always play nice
with Timestamps.

> And another catch is that not all changes in the data
> result in a
> different checksum. A different checksum guarantees
> changes, but an
> unchanged checksum doesn't guarantee that the data is
> unchanged.
> SELECT CHECKSUM('a'), CHECKSUM ('aaaaaaaaaaaaaaaaa')
Yep. It's far more problematic. You can of course roll your
own checksum to get around these problems, but it is a
option depending on how accurate the concurrency must be.

> I couldn't disagree more. The risk of updates being
> overwritten without
> anyone ever noticing is enough justification to take
> whatever steps are
> necessary to prevent this in any serious business.
It's a cost-benefit analysis. Does the substantial
additional development time for all development projects
justify the benefit of handling collisions? If there are few
collisions and the data involved is not that critical, then
it is not justified IMO. Finding other means of preventing
the collisions from happening in the first place is far
better choice if available.
Don't overlook the cost of handling first-write-wins
concurrency. Every system that touches the database has to
know how to deal with it. Every system has to potentially
present users with options about what to do in the case of a
collision. Situations like multiple row deletes (e.g. Delete
From Table Where ForeignKey = Value and thus multiple rows
would be deleted) are much more difficult if not impossible
because someone could have changed a row during the middle
of a delete. Isolation levels become much more of an issue
as some writes must be serialized which adversly affects
scalability. The list goes on. It basically becomes a
problem that has to be dealt with at all tiers of the
application.
It is a massive cost that, IMO, must be justified. Sometimes
it is. Most times it isn't.

> If you don't want the extra complexity, you should
> consider pessimistic
> locking: get an exclusive rowlock when reading the data,
> keep the lock
> as long as the data is displayed on the users' screen and
> only release
> the lock after either the update is made or the user has
> decided to quit
> the screen without saving changes. This will impact
> concurrency, but if
> you expect very few collisions, it won't be a big deal. If
> you expect
> lots of collisions, go for optimistic locking.
Pessimistic locking is even worse and should require an even
*more* extensive justification. There are places where it
makes sense, but they are extraordinarily rare IMO (SCMs are
a good example). Its biggest killer is scalability. Someone
locks a records and walks away from their desk. Now you have
to code timeouts and leases. It requires much more work and
hurts scalability.

> Never use Last Write Wins in any serious multiuser
> business application.
Nonsense. I have seen, and built myself, numerous
successful, large multiuser systems built with
Last-Write -Wins. They were designed such that collisions
could not happen or if, in the oft-chance they did, the
impact was minimal. The benefit of significantly shorter
development time more than justified the cost of an
occasional oddity due to collision.
Claiming that Last-Writes-Wins should never be used is
simply ignorant. It shows a blindness to other possiblities
that make First-Write-Wins unnecessary.
Thomas|||On Thu, 7 Apr 2005 13:20:45 -0700, Thomas wrote:
(snip major part of the post)
Hi Thomas,
Thanks for your post! I won't go into a debate. I think it's good that
both cases have now been defended. The OP can read both our posts,
weight the arguments and counter-arguments, decide how they apply in his
situation and then decide what works best for him. That's what I tried
to accomplish with my post.

>Pessimistic locking is even worse and should require an even
>*more* extensive justification. There are places where it
>makes sense, but they are extraordinarily rare IMO (SCMs are
>a good example). Its biggest killer is scalability. Someone
>locks a records and walks away from their desk. Now you have
>to code timeouts and leases. It requires much more work and
>hurts scalability.
I agree that pessimistic locking is worse than optimistic locking. I
would only consider using it for tables with extremely low update
frequency.
But it won't come as a surprise that I still think that pessimistic
locking is better (or rather: less bad) than Last-Write-Wins :-P
(snip)
>Claiming that Last-Writes-Wins should never be used is
>simply ignorant. It shows a blindness to other possiblities
>that make First-Write-Wins unnecessary.
Okay, I admit that this statement was too bold. I probably should have
written something along the lines of:
IMO, you really need a very strong justification to go with Last Write
Wins. The risk of losing relevant changes without any warning *and* the
consequences of such data should be weighed against the benefit of
reduced complexity and development costs. Because of the possible impact
of unnoticed data loss, this should ideally be a management decision.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Concurency: Oracle vs. MSSQLServer 2K

Hello Gurus,
Im currently reading a Software Engineering for Web Applications Course
which is published online at the MIT (Open CourseWare Site) and here it says
at least it suggests that concurrency behaviour is best in Oracle than in
MSSQLServer. Im SQL Programmer and essentially I love its ease of use and
Id like you guys to comment this transcript. Is it possible to get the same
results in SQLServer by fine tuning the DBMS?
"
Concurrency is Oracle's strongest suit relative to its commercial
competitors. In Oracle, readers never wait for writers and writers never
wait for readers. Suppose the publisher at a large site starts a query at
12:00 PM summarizing usage by user. Oracle might have to spend an hour
sifting through 200 GB of tracking data. The disk drives grind and one CPU
is completely used up until 1:30 PM. Further suppose that User #356712 comes
in at 12:30 PM and changes his email address, thus updating a row in the
users table. If the usage tracking query arrives at this row at 12:45 PM,
Oracle will notice that the row was last modified after the query started.
Under the "I" in ACID, Oracle is required to isolate the publisher from the
user's update. Oracle does this by reaching into the rollback segment and
producing data from user row #356712 as it was at 12:00 PM when the query
started. Here's the scenario in a table:
Time Publisher Public Web Application
12:00 PM Starts a 90-minute query summarizing usage for preceding
year --
12:30 PM usage summary continues to chug away User #356712 updates
email address from "joe@.foobar.com" to "joe@.yahoo.com"
12:45 PM usage summary arrives at User #356712; Oracle reaches into
rollback segment and pulls out "joe@.foobar.com" for the report, since that's
what the value was at 12:30 PM --
1:30 PM usage summary report completes --
How would this play out in Microsoft SQL Server? When you're reading, you
take read locks on the information that you're about to read. Nobody can
write until you release them. When you're writing, you take write locks on
the information that you're about to update. Nobody can read or write until
you release the locks. In the preceding example, User #356712 would submit
his request for the address change at 12:30 PM. The thread on the Web server
would be blocked waiting for the read locks to clear. How long would it
wait? A full hour with a spinning/waving "browser still receiving
information" icon in the upper right corner of the browser window. If you're
thoughtful, you can program around this locking architecture in SQL Server,
but most Internet service operators would rather just install Oracle than
train their programmers to think more carefully about concurrency.
"
--
Jorge Luzarraga C
"I can do it quick. I can do it cheap. I can do it well. Pick any two."SQL Server 2005 contains a feature called "snapshot isolation" that can help
you with this issue.
You really should evaluate the concurrency and data freshness needs of your
application to determine which model you want to use. I personally have
seen cases where the before image was not what the application really
needed. I've also seen cases where it was fine. So, please make sure you
pick what works for your application requirements.
Thanks,
Conor
"Jorge Luzarraga Castro" <jluzarraga@.fidens.cl> wrote in message
news:ubX1kzVFGHA.532@.TK2MSFTNGP15.phx.gbl...
> Hello Gurus,
> Im currently reading a Software Engineering for Web Applications Course
> which is published online at the MIT (Open CourseWare Site) and here it
> says at least it suggests that concurrency behaviour is best in Oracle
> than in MSSQLServer. Im SQL Programmer and essentially I love its ease of
> use and Id like you guys to comment this transcript. Is it possible to
> get the same results in SQLServer by fine tuning the DBMS?
> "
> Concurrency is Oracle's strongest suit relative to its commercial
> competitors. In Oracle, readers never wait for writers and writers never
> wait for readers. Suppose the publisher at a large site starts a query at
> 12:00 PM summarizing usage by user. Oracle might have to spend an hour
> sifting through 200 GB of tracking data. The disk drives grind and one CPU
> is completely used up until 1:30 PM. Further suppose that User #356712
> comes in at 12:30 PM and changes his email address, thus updating a row in
> the users table. If the usage tracking query arrives at this row at 12:45
> PM, Oracle will notice that the row was last modified after the query
> started. Under the "I" in ACID, Oracle is required to isolate the
> publisher from the user's update. Oracle does this by reaching into the
> rollback segment and producing data from user row #356712 as it was at
> 12:00 PM when the query started. Here's the scenario in a table:
> Time Publisher Public Web Application
> 12:00 PM Starts a 90-minute query summarizing usage for preceding
> year --
> 12:30 PM usage summary continues to chug away User #356712
> updates email address from "joe@.foobar.com" to "joe@.yahoo.com"
> 12:45 PM usage summary arrives at User #356712; Oracle reaches
> into rollback segment and pulls out "joe@.foobar.com" for the report, since
> that's what the value was at 12:30 PM --
> 1:30 PM usage summary report completes --
> How would this play out in Microsoft SQL Server? When you're reading, you
> take read locks on the information that you're about to read. Nobody can
> write until you release them. When you're writing, you take write locks on
> the information that you're about to update. Nobody can read or write
> until you release the locks. In the preceding example, User #356712 would
> submit his request for the address change at 12:30 PM. The thread on the
> Web server would be blocked waiting for the read locks to clear. How long
> would it wait? A full hour with a spinning/waving "browser still receiving
> information" icon in the upper right corner of the browser window. If
> you're thoughtful, you can program around this locking architecture in SQL
> Server, but most Internet service operators would rather just install
> Oracle than train their programmers to think more carefully about
> concurrency.
> "
> --
> Jorge Luzarraga C
> "I can do it quick. I can do it cheap. I can do it well. Pick any two."
>|||> Im currently reading a Software Engineering for Web Applications Course
> which is published online at the MIT (Open CourseWare Site) and here it
> says at least it suggests that concurrency behaviour is best in Oracle
> than in MSSQLServer. Im SQL Programmer and essentially I love its ease of
> use and Id like you guys to comment this transcript. Is it possible to
> get the same results in SQLServer by fine tuning the DBMS?
Well, Oracle and SQL Server both appear on this list three times.
http://www.tpc.org/tpcc/results/tpc...=5¤cyID=0
Yes, Oracle appears above Microsoft, but two notes:
(a) Oracle's most recent data is from April 2005
(b) Oracle' average cost is almost 19% higher than SQL Server (avg $7.31 vs.
$6.15), so yes, you can get a bit better performance (even if you believe
the data is valid after that much time) but it's going to cost you a lot
more up front to build the system.
DB2 is at the top of the list, so why does this article choose to only
compare Oracle and SQL Server? Wait, let me guess, it was written by
someone on Oracle's board, or Oracle has made huge investments in MIT's
labs, or...

> How would this play out in Microsoft SQL Server? When you're reading, you
> take read locks on the information that you're about to read. Nobody can
> write until you release them.
That's only with certain isolation levels. You can certainly do a lot of
reading without blocking anyone, either with dirty reads (a.k.a. NOLOCK) or
with the new snapshot isolation in 2005.

> but most Internet service operators would rather just install Oracle than
> train their programmers to think more carefully about concurrency.
Is there any evidence to back this up? How many service providers do you
know of, that provide Oracle as the back end and say, go ahead, build your
database and application around it? I've never heard of one.
There are plenty of ways to design a well-performing application, and while
database vendor choice is certainly a significant factor, it's not the only
one, and it's not the one you end up spending the most time on.
A