Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

MY1201

@MY1201
About
Posts
28
Topics
14
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • [T-SQL] Delete trigger. [modified]
    M MY1201

    Thank you! It worked perfectly! :-)

    modified on Monday, March 10, 2008 4:58 AM

    Database database question help tutorial career

  • [T-SQL] Delete trigger. [modified]
    M MY1201

    Hello everybody. I'm updating an application which makes use of a trigger to maintain relationships between some tables in the database. I was unable to figure out how this could work with a simple constraint, so I thought I would go for a good olde' trigger. :-) Here's the deal: I have two tables: A and B, which both depends on information in table C. Now table C contains some binary data, and some information on how this binary data relates between rows in table A and B. If a row in table A is deleted, all references to that row in table C must also be deleted. The same thing goes for table B. Since entities in table A and B can have the same primary key, the table C use the primary key and a char to determine whether the primary key belongs to table A or B. Therefore I thought a constraint would be out of the question. The trigger problem: The problem is the "DELETED" logical table. As one might have guessed, it only works when there is one row in the DELETED table. The system allows the users to delete multiple rows, so I will have to construct the trigger to maintain relationships for all the rows in the DELETED table. I would most definitely like to avoid using a CURSOR on the DELETED table. How do I do that? :) (Should anyone be able to see how I could construct a constraint for the job, I would also like to know how to do that) Thanks for any help you can provide! :-)

    modified on Monday, March 10, 2008 4:58 AM

    Database database question help tutorial career

  • Disable all textboxes in a page.
    M MY1201

    Hello. I have a problem - and it's probably me not understanding the concept - but I want to programatically disable all controls in my aspx page - if the user watching the page is not authorized to edit the content. Now this should be an easy task, so I've tried a couple of methods like looping through the page's Controls property and have all textboxes set their Enabled property to false. The following code does not work. I'm using a MasterPage, but I can't think of anything, that makes this a problem. When I "ask" the MasterPage to print out the "count" for it's controls property it says there is about 5 items in the list. Although the page contains around 10 TextBoxes! So what am I misunderstanding here? Anyway here's the code:

    foreach (Control c in Page.Controls)
    {
    switch (c.GetType().ToString())
    {
    case "System.Web.UI.WebControls.TextBox":
    ((TextBox)c).Enabled = false;
    break;
    case "System.Web.UI.WebControls.DropDownList":
    ((DropDownList)c).Enabled = false;
    break;
    case "System.Web.UI.WebControls.ImageButton":
    ((ImageButton)c).Enabled = false;
    break;
    default:
    break;
    }
    }

    I hope someone can help! Thanks in advance. Best Regards Soeren

    ASP.NET help design question

  • Causes validation.
    M MY1201

    Hello all! Happy new year! :-) I have a problem with a bizarre ImageButton. It keeps "causing validation". It is part of a table and I use the following code to create it (C#):

    ImageButton cmdDelete = new ImageButton();
    cmdDelete.CommandName = "Delete";
    cmdDelete.CommandArgument = p.DbId.ToString();
    cmdDelete.Command += DeleteRecipient;
    cmdDelete.ImageUrl = "~/Images/trash.gif";
    cmdDelete.CausesValidation = false;
    cmdDelete.OnClientClick = "javascript:Page_ValidationActive=false;";

    1. Causes validation is false. 2. OnClientClick is set to "Page_ValidationActive=false" - which I've heard should be equal to 1., just for the client. Now it behaves like this: The first time it is clicked, it does not cause validation, and the user is deleted and removed from the list. If I click to delete another user, suddenly the button causes validation. If I click it again, it does not! And so on, and so on. I've tried stepping through the code, and every second time the button is clicked, it causes validation. Validation occurs server side, since I've tried turning off JavaScript, and the exact same pattern occurs. I'm kind of confused! LOL! :-) Best regards Soeren

    ASP.NET csharp javascript sysadmin regex help

  • ImageButton.Click event never gets fired!
    M MY1201

    It does produce a postback. I've even tried setting the PostBackUrl property, even though it should not be necessary. My theory is that I forgot to set some property that makes the ImageButton fire its events, but I can't find out which property it is. It makes no sense. :(( Best Regards Soeren

    ASP.NET question csharp asp-net database help

  • ImageButton.Click event never gets fired!
    M MY1201

    It does not work either. Neither the Click or the Command event gets fired. I forgot to write, that I've tried the Click event as well. Btw. the both the command event and the click event should be fired when the ImageButton is clicked. The Command Event gives me the benefit of having access to the CommandArgument, which can tell me the id of the file to be deleted. The click event cannot. Best Regards Soeren

    ASP.NET question csharp asp-net database help

  • RequiredfieldValidator
    M MY1201

    Hello. Do you have another "TextBox1" somewhere on your page? Perhaps in the Master page itself? If so - ASP.NET renames the controls in order to get a unique ID. It should automatically rename your RequiredFieldValidator1 reference to the control as well. But perhaps this does not happen as expected. Anyway you should go check it out. I've found the best way to debug this, is to try and rename your control to something logic eg. "txtName" - that way you ensure, that you decide the names, and not Visual Studio, because, well, it's best the other way around. ;-) Best Regards Soeren

    ASP.NET help

  • ImageButton.Click event never gets fired!
    M MY1201

    Hi guys! I'm creating a web application with a table containing files the users have uploaded to the site. Now for every entry in the table I have a little "trash" icon, so when clicked, the system will delete the file. Now - here is my problem: It doesn't work! Surprise huh! ;) Well it seems like the Command event of the ImageButton never gets fired. I've tried having it throw an exception, but nothing happens, the page just reposts whenever the image is clicked. I do not use the ASP.NET data table WebControl (the one you see in almost every tutorial about ASP.NET and data access) - because it does not fit into my needs. And to be honest: I don't like it that much either. I have this code in my ASP.NET page's CodeBehind file's Page_Load method (please don't think to much about the variable names, as some of them are in Danish):

    // This code sample is part of a foreach loop, so try to imagine
    // that the imgb object gets added to the current table row at the end of every loop.
    // That's also why I set the .ID to "cmd" + the id for the file in the database.
    // Result:
    // The ImageButton turns up on the page, you can click the button, the page reposts
    // and then: nada happens.

            ImageButton imgb = new ImageButton();
            imgb.CommandArgument = b.DbId.ToString();
            imgb.CommandName = "Delete";
    

    // Attach to the Command event - or what?
    // Tried with new CommandEventHandler(this.DeleteFile) - doesn't work either.
    imgb.Command += this.DeleteFile;

            imgb.ImageUrl = "~/Images/trash.gif";
            imgb.ID = "cmd" + b.DbId.ToString();    
    

    I have this code in the "DeleteFile" method, which matches the Delegate for the Command event:

    protected void DeleteFile(object sender, CommandEventArgs e)
    {
        Int32 bilagId = Int32.Parse(e.CommandArgument.ToString());
        BilagHandler.Delete(bilagId);
    
        throw new Exception("wtf!");
    
        FillBilagTable();
    }
    

    The WTF Exception never gets throwed - ergo: The code never executes! Any clues? I'm really confused. And perhaps this post is a stupid question, but I'm just code-blind by now - hey - so be it! :-) BTW: The code compiles without any errors. Best regards Soeren

    ASP.NET question csharp asp-net database help

  • Using a custom user database (should I use a custom MembershipProvider)
    M MY1201

    Oh well stupid me just found out what I think you meant! ;) The solution must be to inherit the Login class, and implement your own version of

    protected void OnAuthenticate(AuthenticateEventArgs e)

    Inside this you do your user validation stuff and set the "e.Authenticated" property to true - if the user validates of course - otherwise false. It seems to do the trick for me.

    If (I'm totally wrong)
    please correct me! :-);

    Best regards Soeren

    ASP.NET database csharp asp-net sql-server design

  • Using a custom user database (should I use a custom MembershipProvider)
    M MY1201

    Okay. Looks nice. I assume this is what you want me to do:

    <asp:Login runat="server" ID="loginBox" OnLoggingIn="LogMeIn">
    </asp:Login>

    And in the "LogMeIn" function I should implement my login validation. Can I be sure, that this will override whatever build in authenticate methods the login contol may have? The reason I'm asking is because the standard setup seems to work against some database in my App_Data folder, without any code at all. Best reagards Soeren

    ASP.NET database csharp asp-net sql-server design

  • Using a custom user database (should I use a custom MembershipProvider)
    M MY1201

    Hello fellow developers! I'm currently working on a website in which users should be allowed to log in. We have an existing user database (SQL Server 2000), and I would like to use this database along with the ASP.NET login controls. Is this possible? I've been researching and found out that a possible solution would be to implement my own version of the MembershipProvider abstract class. Before I wander down that dirty dark road, I would like to know, if there is an easier way. I thought perhaps it would be possible to configure the SqlMembershipProvider to fit my needs. We are unable to change the design of the database since it is part of an existing system. Best regards Soeren

    ASP.NET database csharp asp-net sql-server design

  • Passing objects forth and back between ASP.NET pages.
    M MY1201

    Hi there. I'm currently creating a site which behaves like a kind of "wizard". So I need to pass objects forth and back between the pages in the wizard. Now this works fine passing objects forth, but I have a problem passing objects back or have the page remembering objects between post backs. Here's some example code:

    private MyObject \_myObject;
    
    protected void Page\_Load(object sender, EventArgs e)
    {
        // Context.Items\["MyObject"\] has been set by another page. 
        // An passed on using Server.Transfer()
        \_myObject = (MyObject)Context.Items\["MyObject"\]; 
    
        \_myObject.MyString = "Hello";
    }
    
    protected void Button1\_Click(object sender, EventArgs e)
    {
        MyObjects.SaveMyObject(\_myObject);
    }
    

    Here's my problem: On my web form I have a button which calls "Button1_Click". Whenever this method is called I get a "NullReferenceException" from SaveMyObject - obviously because _myObject is null. But why? In the Page_Load method setting the MyString property to "Hello" works just fine. So my guess is that the page "forgets" the content of the context object between post backs. I guess I need to do something else. Is there some kind of solution to this problem? Best regards Soeren

    ASP.NET csharp asp-net sysadmin help tutorial

  • Where do you put your transaction code?
    M MY1201

    Hey guys. A little question on transaction best practices: 1. Where do you put your transaction control code? I mean: Do you put it in the code (try catch rollback()), or do you put it in the stored procedure? 2. Do you use transactions for simple insert, delete, update sentences? Best Regards Soeren

    Database question database announcement

  • Stored Procedure is not Saving Records
    M MY1201

    Sometimes when I have this problem, it is because I've been sleeping when I created the procedure, and created it in the wrong database. This error usually happens late at night. Have you been sleeping? ;-) Best regards, Soeren

    Database database help announcement

  • Database best practice - large tables.
    M MY1201

    Thank you very much guys! I think this would actually be the solution to my problem! :-D Best regards Soeren

    Database question database sysadmin help tutorial

  • Database best practice - large tables.
    M MY1201

    Of course! I could do that. But what would be the best way to go? I kind of find the idea of making factoryId the primary key a bad idea. I don't know exactly why, but something tells me... Primary Key in one table, but also primary key in another table - well - I don't know. :) UNIQUE constraint could be a way to go. Please correct me if I'm wrong. Best Regards Soeren

    Database question database sysadmin help tutorial

  • Database best practice - large tables.
    M MY1201

    Thanks for the fine example. Except this gives the factory the possibility to have more than one row of pollutiondata. Unfortunately this is not allowed in the datamodel! :(( I created this at first, but it kept getting the system design into trouble. Best regards Soeren

    Database question database sysadmin help tutorial

  • Database best practice - large tables.
    M MY1201

    Colin Angus Mackay wrote:

    If you have 20 non-repeating columns, are they (as a block) optional? In otherwords: Can a factory exist without these values?

    There are no repeating columns in pollution data. Factories must come up with values for some of the columns. Some factories needs to fill in all the columns and others do not. It's Depending on the type of pollution and size of the factory.

    Colin Angus Mackay wrote:

    From what you've said already, regardless of the details of how the data relates, it is obvious that the Factory is the parent. A factory pollutes, without the factory you don't need the pollution data. Therefore, the PollutionData should reference the Factory table. The PollutionData table should have a FactoryId column.

    If I give the PollutionData table a FactoryId this would give me the opportunity to create more than one row of PollutionData referencing the same factory. This is not good since it could give the clients some trouble finding out which one to use. Best regards Soeren

    Database question database sysadmin help tutorial

  • Database best practice - large tables.
    M MY1201

    Hi there! I have a question regarding the structure of a database. I'm currently designing af table that will end up with around 50 columns of different kinds. Now my question is: Would it be better to split the table into smaller tables? I have tried this but I keep running into integrity problems, because the database server will have to delete rows in other tables as well. To clear things up I will give an example: Consider a factory. The factory pollutes. In order to keep track of the pollution, the factory owner has to fill in some 20 values of different kinds. Normally you would place these values on the factory table, but since there are so many of them, you might be able to put the pollution data in another table called PollutionData. But somehow I can't get this to work properbly. I have the factory referencing the PollutionId in the PollutionData table. A cascade delete will only work the other way around! Whenever someone deletes the pollution data, the factory is deleted. Which of course is wrong. I want the pollution data deleted if the factory is deleted. And I want the database server to produce an error if someone tries to delete pollution data referenced by a factory. As I see it - the only way to solve this is to put the pollution columns into the Factories table, but I have this kind "oh noes - this is wrong"-feeling - and that's just because there are so many columns. Any suggestions would be greatly appreciated! :) Best regards Soeren

    Database question database sysadmin help tutorial

  • Int16 is not Int16 are you missing a cast?
    M MY1201

    Hello. I've have this little method (yes - I know it makes no sense - but it is a test): public void AddNumbers() { Int16 a = 2; Int16 b = 4; Int16 c = 6; Int16 result = a + b + c; } The above will not compile. I get the CS0266 compiler error: Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?) But this will: public void AddNumbers() { Int16 a = 2; Int16 b = 4; Int16 c = 6; Int32 result = a + b + c; // or this line: //Int16 result = (Int16)(a + b + c); } Now why is this happening? I've checked the IL code for the method, it looks like this: .method public hidebysig instance void AddNumbers() cil managed { // Code size 14 (0xe) .maxstack 2 .locals init ([0] int16 a, [1] int16 b, [2] int16 c, [3] int32 result) IL_0000: nop IL_0001: ldc.i4.2 IL_0002: stloc.0 IL_0003: ldc.i4.4 IL_0004: stloc.1 IL_0005: ldc.i4.6 IL_0006: stloc.2 IL_0007: ldloc.0 IL_0008: ldloc.1 IL_0009: add IL_000a: ldloc.2 IL_000b: add IL_000c: stloc.3 IL_000d: ret } // end of method Program::AddNumbers As far as I can see IL adds the numbers as ldc.i4. is this integer 4 byte? Because if it is, why does it not get the numbers from ldc.i2. instead? Since my variables are of the type Int16? Can anybody tell me why? Best regards Soeren

    C# question dotnet help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups