Website Found waiting for reply - c#

I am Making a website in ASP.Net on C#. I use 4 queries to get the data from MS SQL Server database. Now the problem is sometime I get the page in browser quickly and sometimes only the "website found waiting for reply" in status bar of IE gettinh nothing..
Please help me out.
Thanks

User Response.flush to forcefully flush the server response.
Use FireBug for client-side debugging.
(source: getfirebug.com)

No this does not happen only when I made any change to code.
Recently I used stored procedure to get the resultset from MS SQl Server database, I add one parameter of type varchar with that the result will be filtered.

Related

asp.NET intranet site: if I try to run multiple reports, one after the other, I get SQL permissions error on stored procedure

I inherited an old asp.NET site. This site uses windows authentication and has several reports. each report makes a separate call to different stored procedures on the SQL server.
If I go to the site and run 1 report, I can run any of the reports. If I try to run 1 report then try to run another report, sometimes I get the error message below:
The EXECUTE permission was denied on the object 'XYZ', database 'ABC', schema 'dbo'
If I hit the back button then try to run any other report, I will get the same error message. I have to close my browser and go back to the site, then it will allow me to run any other report, but only 1 report (if I try to run a second report, I get the same error message).
This happens most of the time. Sometimes I can run all the reports without getting an error message, but most of the time I get the error message on the 2nd report I try to run.
I don't think this is a permissions issue, since I have permissions and can run all of the reports, I just have to close the browser after each report I run. I don't know when this issue started or what changed to cause it to happen. I am really at a loss and don't even know where to start.
Thanks in advance for your help.

C# creating a database programmatically with SMO

I am trying to create a database, but once created, I cannot connect to it.
The server is Microsoft SQL Server 2008 and using .Net 4.5. We're creating the database with SMO, but we're usually using Dapper to connect and query the database.
This is the code I have so far, which works :
System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(connectionString);
Microsoft.SqlServer.Management.Smo.Server srv = new Microsoft.SqlServer.Management.Smo.Server(new Microsoft.SqlServer.Management.Common.ServerConnection(con));
var database = new Microsoft.SqlServer.Management.Smo.Database(srv, dbName);
database.Create(false);
database.Roles["db_datareader"].AddMember(???);
database.Roles["db_datawriter"].AddMember(???);
database.Roles["db_backupoperator"].AddMember(???);
srv.Refresh();
Noce the ??? ? I have tried
System.Environment.UserDomainName + "\\" + System.Environment.UserName
and
System.Environment.UserName
but it fails (update) with the error Add member failed for DatabaseRole 'db_datareader'. with both values.
The problem is that when I create the database, I cannot coonect to it for some reason (using Dapper), from the same program. (update) I get the error message : Cannot open database \"<database_name>\" requested by the login. The login failed.\r\nLogin failed for user '<domain>\\<username>' (where <database_name> is the database name, <domain> my logon domain, and <username> my Windows logon).
Am I missing something? Am I doing th right thing? I've tried searching the web, but it seems no one creates database this way. The methods are there, it should work, no?
** Update **
If I comment the database.Roles["..."].AddMember(...) lines, and I add a break point at srv.Refresh(), resuming the program from there solves everything.
Why a break point solves everything? I can't just break the program in production... nor break the program when creating the database everytime.
It sounds like the Dapper connection issue is a problem with SQL Server doing some of the SMO operations asynchronously. In all likelihood, the new Database is not ready for other users/connections immediately, but requires some small time for SQL Server to prepare it. In "human-time" (in SSMS, or a Breakpoint) this isn't noticeable, but "program-time" it too fast, so you probably need to give it a pause.
This may also be the problem with the Role's AddMember, but there a a number of things that could be wrong here, and we do not have enough information to tell. (specifically, does AddMember work later on? and are the strings being passed correct or not?)
This is happening because you've created the user, but no login for that user. Though I don't know the exact syntax, you're going to have to create a Login. You'll want to set its LoginType to LoginType.WindowsUser. Further, you'll likely need to set the WindowsLoginAccessType to WindowsLoginAccessType.Grant and you'll need to set the Credential by building one, probably a NetworkCredential with the user name you want.
To put a visual on this, the Login is under the Security node for the Server in Management Studio whereas the User is under the Security node for the Database. Both need to exist for access to the SQL Server.

datatable serialization does not work as expected

I have a winforms client application which is written in c# 4.0 that sends
a simple datatable (in a dataset) to the server , which is written in vb.net 4.0.
The datatable is sent through a web service.
both client and server are on the same computer.
This has been working fine for many years.
Now I get a strange behaviour with a datatable generated from a csv file.
Here it how it looks on the client side:
and here is the server side:
for some reason, the first row time has shifted from 2:55 AM to 03:55 in the server.
This results in a duplicate key. what's up with that?
one of the strangest bugs I've ancountered. would appreciate any help with this one -
thanks.
As suggested by #mikey,
the problem was that client used a local user account
whereas the server used the IIS acount.
One of those acounts was set to use daylightsaving time,
the other was not.
In my country, daylight saving time ended on march 29,
so this resulted in a conflict between server time and client time,
even though both were on the same computer.
Mikey , thanks again :)

I can exec my stored procedure in SQL Server Management Studio but webservice can not

I have a webservice method that executes a tabular stored procedure. This sp takes 1 minute to be executed completely. I call that webservice method remotely and get results.
In normal situations everything is OK and I get results successfully.
But when the server is busy the webservice can not execute that sp (I tested it in SQL Profiler and nothing comes to profiler) but I can execute that sp manually in SQL Server Management Studio.
When I restart SQL Server, the problem is solved and the webservice can execute sp.
Why in busy situations webservice can not execute sp but I can do it in SQL Server Management Studio?
How this situation can be explained? How can I solve that?
Execute sp_who and see what is happening; my guess is that it is being blocked - perhaps your "isolation level" is different between SSMS and the web-service.
Equally, it could well be that the connection's SET options are different between SSMS and the web-service, which can lead to certain changes in behavior - for example, computed-stored-indexed values are very susceptible to SET options: if the caller's options aren't compatible with the options that were set when the column was created, then it can be forced to table-scan them, recalculating them all, instead of using the pre-indexed values. This also applies to hoisted xml values.
A final consideration is parameter sniffing; if the cache gets generated for yourproc 'abc' which has very different stats than yourproc 'def', then it can run very bad query plans. The optimize for / unknown hint can help with this.

Restore a Database Programatically (SQL Server)

I recently found this link which shows a great example of backing up and restoring a sql server database. However, my SQL Server only uses WindowsAuthentication and so it does not really require a UserName and Password. To be able to do this, I turned the line srvConn.LoginSecure = false; into srvConn.LoginSecure = true;
I was expecting to connect succesfully to the Server. However, this example returns an exception saying that it was unable to connect to the server.
Can anybody help me please? I have to learn this application for me to be able to apply the same concept to a project i'm working on. Thank you very much.
First of all if you want to enable remote connection to your server (I'm not sure if this is what you're after), Try this: http://support.microsoft.com/kb/914277 . You will also want to make sure the mixed authentication option is enabled.

Categories

Resources