You should be using WebForms not WinForms for an asp.net web app. didn't mean to post twice - connection error on my end
Member 4501940
Posts
-
Error when loading ASP.NET page -
Error when loading ASP.NET pageWinCrs wrote:
'Microsoft.ReportViewer.WinForms'
is for windows applications. For web apps: 'Microsoft.ReportViewer.WebForms'
-
performance issueAgree with digital man. First thing to look at is SQL. Also, does the site have images for the products? Are these optimized? How are they handled? Are you storing in db? Need to see some code to help more...
-
user should not login again if he is loggedin once during same browser [modified]Gmail - Your assumptions are not accurate. If you do not 'sign out' of gmail in mozilla, it will open the inbox page. Same with IE. IE and mozilla operate completely independant of each other. This behavior is usually acceptable. Assuming you are using the aspnet membership provider, you can test 'signout' functionality using
FormsAuthentication.SignOut();
. Anytime the signout is used, I also kill the session usingSession.Abandon();
. The membership provider behaves similar to gmail if that is the desired result. -
user should not login again if he is loggedin once during same browser [modified]Session variables are not shared from window to window like that. If using forms authentication, this is what you are looking for.
if (this.User.Identity.Name == "Admin") { Response.Redirect("Admin/AdminHome.aspx", false); }
Normally you would do this the other way around. If the user tried to access AdminHome without being logged in, send them to the login and bounce them back from there if successful login.
-
Passing value to confirmation boxYes, you are so right. I am 'old-school' and use mostly server-side confirmations.
-
Passing value to confirmation boxIn order of preference: 1 - Include that column as a DataKey in the DataKeyNames property of the GridView. 2 - Use the column as a CommandArgument property of the Button. 3 - Use a HiddenField.
-
Insert record in Identity field of table using CommandBuilderAn identity field can not be set using insert. It will be auto-incremented by sql. If you want to intially set the values because you need to seed the table with pre-existing values, remove identity, insert values, then turn back on. On an on-going basis, if you want to control the values in the identity column, you will not want to have the field as an identity column at all. sqlbulkcopy does have an keepidentity option. http://msdn.microsoft.com/en-us/library/tchktcdk(VS.80).aspx[^] For performance reasons, I would handle the identity outside of the sqlbulkcopy process as well as other contraints and indexes. Depends on what, how often, how much...
modified on Thursday, March 25, 2010 9:27 AM
-
How to open PDF from server?The files do not have to be in 'my project' but they do have to be in an internet share that have the proper permsissions set. IIS and aspnet do not have full run of the OS and can not directly access server paths as you mentioned without punching some big holes in security. So. Create a share, set permissions and you are good to go.
-
Rowspan in html table according to the record from DB....Yes, that whole logic thing will get you everytime.
Dim connection As New SqlConnection("server=MyServer;Trusted_Connection=true;database=MyDatabase")
connection.Open()
Dim command As New SqlCommand("select MyKey,MyField1,MyField2 from MyTable order by MyKey;", connection)
Dim reader As SqlDataReader = command.ExecuteReader()Response.Write("<table border='1'>")
'Read the first record
reader.Read()
'Set the control break
Dim ControlBreak As Integer = CInt(reader(0))
'Write all cells
Response.Write("<tr><td>" & reader(0) & "</td><td>" & reader(1) & "</td><td>" & reader(2) & "</td></tr>")While reader.Read()
If reader(0).Equals(ControlBreak) Then
'Write some cells
Response.Write("<tr><td colspan='2'> </td><td>" & reader(2) & "</td></tr>")
Else
'Reset the control break
ControlBreak = CInt(reader(0))
'Write all cells
Response.Write("<tr><td>" & reader(0) & "</td><td>" & reader(1) & "</td><td>" & reader(2) & "</td></tr>")
End If
End While
Response.Write("</table>")
reader.Close()
connection.Close() -
Rowspan in html table according to the record from DB.... -
Rowspan in html table according to the record from DB....The requirement is simply using 'control break logic'. Search for it. Note that the sort order of the recordset is important. Read the first record. Save the 'control break' (userid?, can be more than 1 value). Write_All_Cells. For every record after that... Read. If value same as saved 'control break' then Write_Some_Cells (one td has a column span = n) else replace control break value Write_All_Cells
-
Best Practices Q"When inserting or updating via proc that it is a good practice to return the new or updated rec using output parameters." Opinions - one way or the other - appreciated. Thanks
-
Help me understand this unusual query... [modified]Something is wrong...in ansi sql databases: The rows returned in the first query will be equal to or greater than the second. All of the rows in the second will be included in the first. The rows returned in the third query will never be in the first or second. Need to figure this out before thinking about indexes and wildcards. I would change the second qry as such:
WHERE tblField1 = char(32)
just to be sure because-select ascii(' ') --this equals 9
select ascii(' ') --this equals 32Create and put data in your Table1 and test if you are not convinced.
-
transaction errorYou have a begin tran on the outside of a while loop and have a rollback on the inside with an unconditional commit on the outside. If a rollback occurs, the loop continues transaction-less and the commit will execute anyway = your error 3902. I would not wrap a transaction around a while loop if there was another way (there is!). Never issue a commit or rollback without checking to see if there is actually a tran.
if @@trancount > 0 rollback transaction
I would use a try-catch, without a doubt. Heres generally how a transaction could be handled:
begin try
begin transaction--dml statement here
if @@trancount > 0
commit transaction
end trybegin catch
if @@trancount > 0
rollback transaction
print error_message() --(execute my error handler)
end catchSome of the other wierd messages you are getting is because the proc failed to issue a commit or rollback at all leaving 'things' in an un-committed state. Until you have verified that the proc you are developing will always close the trans - issue either a commit or rollback after each 'test'.
-
Table rows vs. comma separatedYes, lots of experience. Just finished a db optimization contract(job). The client was adding a million records every couple of days. Have been doing the same for 20+ years. The Receive Table may have a lot of records in it but only 2 columns and those columns will make up the primary key. To query for a given record, you will use the pk. Clustered, indexed, primary key 2 columns only - should be able to get any given record in about 3 milliseconds or less with 10 million records in it. Subtract a ms or 2 if your id values are numeric. This type of table will not take up much space. This will be thousands of times faster than searching for a partial string value in text where you will won't be able to find the user by using an index - at all. (not easily anyway) Searching for a string in a text type field is a VERY time consuming operation for a db to do - not a good idea. I would create test scripts and data to validate if you're not convinced. Let me know if you need help. What db are you using?
-
How to identify the ID of row which has been modified?I concur. This is NOT the place for a trigger. I only use triggers to store 1)disposable, 2)derived and 3)complex data used for reporting or searching. Must meet all 3 criteria. But to answer the question-
UPDATE Demo
Set BeModified = 1 WHERE ID IN (SELECT ID FROM inserted)OR
UPDATE Demo
Set BeModified = 1
FROM Demo
INNER JOIN inserted
ON Demo.ID = inserted.IDThis is assuming sql server. The "inserted" table is a virtual table which contains all of the fields and values from the insert, update or delete that fired the trigger. You might think that only a record at a time is updated but in fact since it is possible to update multiple records at the same time, this may NOT be what you want. But thats what you get with triggers. If you ever have to update all of the records in that table, BeModified will be set to 1 for all. Be warned.
-
Table rows vs. comma separatedassuming that the recipient list are also users User Table Columns UserID+User Message Table Columns MessageID+Message Sent Table Columns UserID+MessageID (using the senders user id) Receive Table Columns UserID+MessageID (using the recipients user ids) use csv if recipients are not users or you don't need to track don't use csv if you intend to parse later - not effective
-
need query to calculate amountEither of these will work if using sql server
with temp (ReceiptNo, CustomerID, Amount)
as
(
SELECT ReceiptNo, CustomerID, Amount
FROM customer
group by ReceiptNo, CustomerID, Amount
)
select CustomerID, sum(Amount) from temp group by CustomerID
GO/*** or this one ***/
SELECT ReceiptNo, CustomerID, Amount
INTO [#temp]
FROM customer
GROUP BY ReceiptNo, CustomerID, Amount
select CustomerID, sum(Amount) from #temp group by CustomerID
GOdrop table #temp
GO -
"Top Rated Video" Sorting algorithmTo be honest, you have to lie! You could assume that every video has the same number of votes. The votes that are not 'real' would be neutral or average. If your scale is 1-5 and every video has the same number of votes then the video with the one vote at 5 also has 199 at 2.5. ((199*2.5)+(1*5))/200 video 2 needs 176 votes at 5 to equal video 2's rating better still assume all videos have 1000 votes (or whatever) - still works out the same video 1 with 200 votes at 4.7 (200*4.7+800*2.5)/1000=2.94 video 2 with 1 vote at 5 (1*5+999*2.5)/1000=2.503 video 2 with 176 votes at 5 (176*5+(1000-176)*2.5)/1000=2.94