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
L

Lukasz Nowakowski

@Lukasz Nowakowski
About
Posts
115
Topics
10
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Auto-increment value on UPDATE
    L Lukasz Nowakowski

    I think that's the best approach. It should work for all updates. Second way I can think of is to create procedure for updating the table and using it for all updates, that occur. And inside this procedure you can also update your version and modified columns. But that required you to stick with the procedures for all updates.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# database announcement question

  • Problem with configuration reading
    L Lukasz Nowakowski

    I have a problem with configuration files (Windows Forms application). I'm developing an application, that is supposed to be using plug-ins. Plug-ins are enclosed into a dll, that is put into 'plugins' subdirectory in the application root. Each plug-in can have it's own setting, so to make it comfortable to use I want to have configuration of each plug-in in separate config file (for example when plugin1.dll needs some settings it is stored in the plugin1.dll.config). I wanted to access configuration through the config section (I don't like the "settings" section and it doesn't work for some of my scenarios). I have now class Plugins.Plugin1.Settings that derives from ConfigurationSection and a section in the app.config that points to this type. I point this type with fully qualified name (I mean with assembly name: 'Plugins.Plugin1.Settings, Plugins.Plugin1'). Everything seems fine. I copy Plugins.Plugin1.dll and Plugins.Plugin1.dll.config to 'plugins' directory and run the application. When I try to access settings I get exception saying, that there was an error creating configuration section module, because assembly Plugins.Plugin1 or one of it's dependencies could not be loaded. Stupid thing about this (for me) is that the code, where exception is thrown from inside the Plugins.Plugin1 code. I suppose the problem is that Plugins.Plugin1.dll isn't located inside 'bin', but inside subdirectory, but I can't throw it to bin, cause it isn't part of the main code, it's just an extension. How can I load data from this configuration file? Searched the web all day and didn't find anything usable... maybe I was asking Google the wrong questions ;-)

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    .NET (Core and Framework) help question winforms tutorial workspace

  • Multi-lingual possessive case
    L Lukasz Nowakowski

    Well... Another way could be to do with String.Format. // retrieve formattingString from resource string.Format(formattingString, "John Smith"); And now for English you can have resource: "{0}'s photos". For Polish you could have: "Zdjęcia należące do użytkownika {0}". And although it is quite long, it is grammatically valid. But you have to create a version for each language you support :-)

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# question csharp lounge

  • Multi-lingual possessive case
    L Lukasz Nowakowski

    I don't think you can do that a generic solution. In English it's easy, but in Polish you would have something like this: The name: "Jan Kowalski". Possessive case: "Jana Kowalskiego". You see, in Polish we have 7 (seven) cases. And those are applied to both first name and last name. Similar situation also applies to Russian, Czech and other Slavic languages. Don't know many others, but generally, you can't create generic solution for all languages.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# question csharp lounge

  • Page Navigation
    L Lukasz Nowakowski

    First of all, I don't understand why you want to redirect after sending anything to browser. Didn't check that in VS, but believe the problem is that you are modifying response, and then doing Response.Redirect. Try removing lines: Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Export.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Write(pdfDoc); Response.End(); And check if Response.Redirect works.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# sysadmin help question

  • architecture
    L Lukasz Nowakowski

    I think better approach may be to go backwards to what you written. So first you create a GUI for a functionality. Then you write some logic of the GUI, that calls service, which in turn calls business layer method/methods and business layer performs operations on database. In this approach important thing is not to implement all layers at once. First you design GUI. Because GUI is most important in the application (this is what user sees and he really doesn't care, that underneath there is super database design if GUI sucks). When you have GUI, you can prepare some logic for it. Here you decide what services you need and create interfaces of these services. You don't implement services yet. You just create some implementation that returns constant data. When logic of GUI is completed you can start implementing services for real. Implementation of services gives you idea of what business layer should contain and you do the same with business layer as with services earlier: simple implementation without real logic. In the end you create data access layer. And database. And they are result of what you really need, not what you think you'll need.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# architecture asp-net database wcf business

  • C# and SQL Server :: Find Most Common Via Junction Table
    L Lukasz Nowakowski

    I don't know if I understand correctly your issue. I understand the issue is, that you have tables: 1. [Repaired item] ([Serial Number], [Some data about item]) - stores information about items, that are repaired (car, or whatever). 2. [Failure Codes] ([Failure Code], [Information about failure]) - stores information about failures, that can be repaired. 3. [Repair Data] ([Serial Number], [Failure Code]) - stores connection between [Repaired item] and [Failure Codes]. With the structure above you want (for the given [Serial Number]) find the failure that occurs most often. If the above is correct, then I think you should do this in SQL using the following query:

    SELECT
    [Serial Number],
    [Failure Code],
    COUNT(*) AS [Counter]
    FROM
    [Failure Codes]
    WHERE
    [Serial Number] = @SerialNumber
    GROUP BY
    [Serial Number],
    [Failure Code]
    ORDER BY
    [Counter] ASC

    And you can retrieve it easily from C# without any loops.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# database csharp sql-server sysadmin help

  • Auto Login Via a Link
    L Lukasz Nowakowski

    No. It's a description of the application.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# xml wpf sysadmin

  • What is this line?
    L Lukasz Nowakowski

    I just checked, cause I wasn't sure... string is just a reference type, that acts like value type. So it can point to a null reference of course. My mistake ;-)

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# question

  • What is this line?
    L Lukasz Nowakowski

    Roger Wright wrote:

    The ? operator can be used with any type, for what it's worth.

    No. It can only be used with value types (int, double, decimal, DateTime). It cannot be used with reference types. And it cannot be used with strings.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# question

  • Classes inheritance and something that confuses me
    L Lukasz Nowakowski

    You have Employee instance and you assign an instance of the ContractEmployee to it. So you can do something like this (I'll take example from Wayne Gaylard):

    class Employee
    {
    public void Talk()
    {
    MessageBox.Show("I am an Employee.");
    }
    }

    class ContractEmployee: Employee
    {
    public void ContractTalk()
    {
    MessageBox.Show("I am a Contract Employee.");
    }
    }

    Then you can do:

    static void CreateEmployee()
    {
    Employee e = new ContractEmployee();
    e.Talk();
    ((ContractEmployee)e).ContractTalk();
    }

    But you can't do:

    static void CreateEmployee()
    {
    Employee e = new Employee();
    e.Talk();
    ((ContractEmployee)e).ContractTalk(); // Here you will get an exception at runtime. Compliler won't find any errors.
    }

    On this example it seems useless, but it is sometimes useful. For example you can have a class structure of different user type, all inheriting from User, you can store them on in a collection of Users

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# question csharp oop tutorial learning

  • Getting values from enum with [Flags] attribute
    L Lukasz Nowakowski

    Maybe I'm to tired, but I don't see how does it brakes those guidelines. I have Value1, Value2, Value3 and Value4 as my enumeration values, and for "commonly used flag combinations" I have: Value13, that means Value1 OR Value3 and Value24, that means Value2 OR Value4 Value13 and Value24 mean "Value 1 or 3", "Value 2 or 4", not "Value 13", "Value 24". Obviously, this enum is just an example and in my real code it's more meaningful.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# data-structures question

  • Getting values from enum with [Flags] attribute
    L Lukasz Nowakowski

    Great. Didn't thought of this. Thanks.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# data-structures question

  • Getting values from enum with [Flags] attribute
    L Lukasz Nowakowski

    Yeah. I know this. But I want to filter out values that are combination of two or more other values in the enum. So when I have: Value13 = Value1 | Value3 I want it to be filtered out.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# data-structures question

  • Getting values from enum with [Flags] attribute
    L Lukasz Nowakowski

    I tried to find it, but Google today doesn't like and doesn't want to tell me this. I have an enum: [Flags] enum EnumName { None = 0, Value1 = 1, Value2 = 1 << 1, Value3 = 1 << 2, Value4 = 1 << 3, Values13 = Value1 | Value3, Values24 = Value2 | Value4 } How can I extract from this enum values that are "simple values"... I want to get collection, array, whatever, that will store values: None Value1 Value2 Value3 Value4 I have a couple of enums like this, so "just create a list of those values" isn't good. Also this list is a subject of changes, so I want it to be done automatically after compilation.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# data-structures question

  • c# application hang plz help
    L Lukasz Nowakowski

    1. You should use <pre> or <code> tag to format code properly. 2. You should debug your application and try find the problem yourself. You just wrote some code, it doesn't work, so you think someone on the internet will fix it for you? 3. Connected to number 2 - you should tell us more specifically, what the problem is. "application hang" in the subject isn't telling us to much. You think we will run your code and check, where does it hang? We won't. Firstly you only gave us part of the code ("code-behind" of your form), and we don't know what controls you have on this form. Secondly, it's your job to locate the problem, and then we can tell you how to fix it. And if you can't locate the problem, than you should find at least a piece of code, that's causing it. Most of us here are willing to help, but you should show us, that you've done something to solve the problem yourself.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# csharp graphics json help

  • how to fill a combobox with a class
    L Lukasz Nowakowski

    You should use this. And additionally you should notice, that OnLoad method should have only one argument: EventArgs e

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# question database tutorial

  • how to fill a combobox with a class
    L Lukasz Nowakowski

    You don't. You create class:

    public class NationSelector : ComboBox
    {
    protected override void OnLoad(EventArgs e)
    {
    string nacionalidad = "select * from cs_nacionalidad";
    try
    {
    //open connection
    bdConex.OpenConnection();
    //create command and assign the query and connection from the constructor
    MySqlDataAdapter da = new MySqlDataAdapter(nacionalidad, bdConex.conn);
    //create dataset
    DataSet ds = new DataSet();
    // filling dataset
    da.Fill(ds, "cs_nacionalidad");
    //dataset values
    cboNacionalidad.DataSource = ds.Tables["cs_nacionalidad"];
    cboNacionalidad.DisplayMember = "nm_nacionalidad";
    cboNacionalidad.ValueMember = "cd_nacionalidad";
    //close connection
    bdConex.CloseConnection();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }
    }

    And then, when you edit your aspx (or ascx), in the toolbox you should see "NationSelector". And you just drag this control on the designer.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# question database tutorial

  • how to fill a combobox with a class
    L Lukasz Nowakowski

    You can create a class, that derives from ComboBox, and there you do

    protected override void OnLoad(EventArgs e)
    {
    string nacionalidad = "select * from cs_nacionalidad";
    try
    {
    //open connection
    bdConex.OpenConnection();
    //create command and assign the query and connection from the constructor
    MySqlDataAdapter da = new MySqlDataAdapter(nacionalidad, bdConex.conn);
    //create dataset
    DataSet ds = new DataSet();
    // filling dataset
    da.Fill(ds, "cs_nacionalidad");
    //dataset values
    cboNacionalidad.DataSource = ds.Tables["cs_nacionalidad"];
    cboNacionalidad.DisplayMember = "nm_nacionalidad";
    cboNacionalidad.ValueMember = "cd_nacionalidad";
    //close connection
    bdConex.CloseConnection();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }

    And then use this class, where you want ComboBox to contain this data.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# question database tutorial

  • Web service in asp.net using c#
    L Lukasz Nowakowski

    My first idea: I see you have connection strings hardcoded into your source code. Are you changing them before uploading to match configuration from the hosting server? If not, it can't work, because (most likely) your service cannot find server DANDAN-PC, nor file "C:\\MemberSites\\MemberSites_AspSpider_Info\\akosiDAN\\database\\Database1.mdb". You should move both those connection strings to the web.config file.

    Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

    C# csharp database help asp-net sql-server
  • Login

  • Don't have an account? Register

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