|
What about them ?
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Hmmm bacon
oops sorry invasion of a random though!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Seems to be happening a lot in here today
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
In a C# 2010 application, I used linq to sql to setup my database connections.
Now when I move the application to a different database, the original database is still being used. Basically the connection string is hard coded into theapplication.
I tried to follow the linq listed below, but everything did not work.
http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/
The part that says, "1.Open up the LINQ to SQL designer, and open the Properties tab of the designer (the schema itself),
expand Connection and set Application Settings to False. ", I did not see this option.
The closest thing I found was connection and I set that value.
Here is the way the code looks now in the *designer.cs file.
namespace e_ClScripts
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="DEV")]
public partial class eDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
#region Extensibility Method Definitions
partial void OnCreated();
partial void Inserte_Detail(e_Detail instance);
partial void Updatee_Detail(e_Detail instance);
partial void Deletee_Detail(e_Detail instance);
partial void InsertIBook(IBook instance);
partial void UpdateIBook(IBook instance);
partial void DeleteIBook(IBook instance);
partial void InsertIPackage(IPackage instance);
partial void UpdateIPackage(IPackage instance);
partial void DeleteIPackage(IPackage instance);
partial void InsertIError_Tran(instance);
partial void UpdateIError_Tran(IError_Tran instance);
partial void DeleteIError_Tran(IError_Tran instance);
partial void InsertTransaction_Type(Transaction_Type instance);
partial void UpdateTransaction_Type(Transaction_Type instance);
partial void DeleteTransaction_Type(Transaction_Type instance);
partial void Inserte_Tracking(e_Tracking instance);
partial void Updatee_Tracking(e_Tracking instance);
partial void Deletee_Tracking(e_Tracking instance);
#endregion
public eDataContext() :
base(global::e_ClScripts.Properties.Settings.Default.DEVConnectionString, mappingSource)
{
OnCreated();
}
public eDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public eDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public eDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public eDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
Here is what the app.config file looks like right now:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="e_ClScripts.Properties.Settings.DEVConnectionString"
connectionString="Data Source=instance1\DEV;Initial Catalog=dev3;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Can you tell me or show me in code how to fix my problem so the application does not
use the hard-coded values that were setup by linq to sql?
|
|
|
|
|
I don't use Linq to SQL but we have different config files for each environment. The UAT config file will have a different connection string pointing to the UAT server, when you compile for deployment you chose the config you want to use and make sure the config file has the correct connection string.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You are correct that each database has a different connection. However in code, can you show me how to change the connection string and how to change the app.config file to point to the different databases?
The way that linq to sql works is it hard codes the connection string. I want avoid this hardcoded connection string.
|
|
|
|
|
It is not a coding problem take a look at ConfigurationManager[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
sc steinhayse wrote: connectionString="Data Source=instance1\DEV;Initial Catalog=dev3;Integrated Security=True"
Err...That is your connection string. It is in your app.config.
So if you want it to point to a different database then you change that.
If however that is not where your connection string is coming from then it is certainly coming from somewhere so use a text editor to search ALL files you in your source tree for the connection information.
|
|
|
|
|
I need to crate a new class which replicate a class in a given assembly but adding also a new constructor and adding new methods. Is it possible?
|
|
|
|
|
Yes, it's called inheritance and is a cornerstone of OOP.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If the class is a class (and not a struct) and isn't sealed then you can inherit from it:
public class YourClass : OriginalClass
{
public YourClass(...) : base(...)
{ }
}
If it's a struct or a sealed class then you will need to create a wrapper and replicate all the constructors/properties/methods etc you require:
public WrapperClass
{
private WrappedType value;
public WrapperClass(...)
{
value = new WrappedType(...);
}
public void DoSomething()
{
value.DoSomething();
}
}
|
|
|
|
|
in may case the base class have not a parameterless constructor, while in the derived I need this one.
Is it possible to istantiate the base class in later mathod?
|
|
|
|
|
Not by using inheritance - you would need to use a wrapper as in my second snippet, the base would stay null until instanciated.
|
|
|
|
|
You cannot do it later in a method, but if you know the parameters, you can do it like this:
class BaseClass
{
public BaseClass(int theParam)
{
}
}
class DerivedClass : BaseClass
{
public DerivedClass() : base(4711)
{
}
}
|
|
|
|
|
Hello experts,
First of all I have average experience with .Net programming, so please go easy on me .
I have an windows application project that consists of 10 Forms. At the moment when I compile my app, it generates a single Exe file. Everything works good.
I want to write an update program for my application, and also after reading some best practices on how to build your app i realized I also need a lot of code rewriting in order to make my app look good.
The thing is I am thinking it would be better to split each form into a separate DLL file, this way achieving some form of modular structure and make my app easier to manage and update.
The problem is I don't have enough experience to know whether splitting each Form into a separate DLL is a good idea or a bad idea, so I'm asking you guys to tell me, from your experience, how would you structure such a project and what would the expected files be ?.
Thank you for your time, and I hope I made myself understood.
Andrei
|
|
|
|
|
In general, you won't see any benefit from splitting the forms out into separate DLLs. When you read about modularisation, people tend to be talking about splitting out application logic, rather than the presentation tier. So, you can split out the actual logic, which is fine, but you should leave the forms where they are.
|
|
|
|
|
Thank you for the answer.
I will give this some more though. Each form I have is part of a module of the application logic.
So I thought it would be recommended to split them into DLL's or more experienced programmers would split the forms at presentation level too.
Maybe I will just leave it as it is, because it is working fine so far and I will write an update program that overwrites the entire exe file instead of particular DLL files.
-
Andrei
|
|
|
|
|
10 forms is fairly small as apps go, I'd leave it in the single exe. It is usual to divorce the UI from the business logic and the database functions. I'd assume that all your business logic is in the code behind the form, this is usually extracted into a separate class.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How to convert PPT to image without using MS Office , Can we do it with Open Office ?
I did it with MS-Office but it need to be installed Ms-Office on Server.
POWERPOINT.Application App = new Microsoft.Office.Interop.PowerPoint.Application();
POWERPOINT.Presentation pres = App.Presentations.Open(fileName, OFFICECORE.MsoTriState.msoTrue, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse);
int pageNo = 0;
pres.SaveAs(imagePath + "\\Images", POWERPOINT.PpSaveAsFileType.ppSaveAsPNG, OFFICECORE.MsoTriState.msoFalse);
|
|
|
|
|
Hi..
how to report the single record into crystal report ..
here i am enter user id in text box then display the user information in crystal report based on the user id....
please give me ans..
|
|
|
|
|
You question is too broad, get a tutorial on Crystal Reports and work through it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Say my performance is approx 50ms per request (request initiated from one port on local machine to another port SAME machine), each request contains about ten rows of data (2 columns only).
What's your thought on this performance level?
(I know some algo trading execution say from London to NY can be done in say 50-60ms ...)
dev
|
|
|
|
|
Is this a C# issue?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
it's not an issue, just testing water see how people feels about 50ms per call if it's considered slow/acceptable/fast
dev
|
|
|
|
|