|
Throw some columns out, use a very small font, change the layout..?
|
|
|
|
|
I already have set the font size to 7 but still its the same. They overlap. I can't omit the other columns because they are required information. For the layout, how do you set that? Are you referring to the list of layouts of the crystal report like "Drop Table?"
|
|
|
|
|
Hey,
I now this i kind of a broad question, if not completly trivial, but how would one program a c sharp application that would only need to open a sqlconnection once. For example:
SqlConnection mySqlConnection = new SqlConnection("server=(local)\\SQLEXPRESS;database=cache;Integrated Security=SSPI;");
SqlCommand mySqlCommand = mySqlConnection.CreateCommand();
mySqlConnection.Open();
This works fine and all but i can only access the Sql command inside that class and have to open a new sql connection if i am to use this command again... Hope this is explain good enough...
|
|
|
|
|
You do exactly that, Create the SQL connection only once, and pass the object around as a parameter to wherever you need to use it.
Or you could use the singleton pattern[^] to make it available globally (but this would be considered quite bad practise)
SQL server actually pools it's connections internally, so you will find that even if your app creates a new connection every time it needs data, SQL server will most likely be reusing the same connection every time, so if it's performance you are worried about, don't worry, it's probably already being taken care of.
Simon
|
|
|
|
|
Ok, so how would i for example make use of my "mySqlCommand" command in another class?
modified on Thursday, November 27, 2008 9:24 AM
|
|
|
|
|
Pass it around as a parameter to a constructor or method, or as a property:
class Program
{
static void Main(string[] args)
{
SqlConnection connection = new SqlConnection("YourConnectionString");
ClassA a = new ClassA(connection);
a.DoStuff();
ClassB b = new ClassB(connection);
b.DoStuff();
ClassC c = new ClassC();
c.DoStuff(connection);
ClassD d = new ClassD();
d.ConnectionForD = connection;
d.DoStuff();
}
}
public class ClassA
{
private SqlConnection _sharedConnectionInA;
public ClassA(SqlConnection connection)
{
_sharedConnectionInA = connection;
}
public void DoStuff()
{
_sharedConnectionInA.Open();
}
}
public class ClassB
{
private SqlConnection _sharedConnectionInB;
public ClassB(SqlConnection connection)
{
_sharedConnectionInB = connection;
}
public void DoStuff()
{
_sharedConnectionInB.Open();
}
}
public class ClassC
{
public void DoStuff(SqlConnection connectionForC)
{
connectionForC.Open();
}
}
public class ClassD
{
private SqlConnection _sharedConnectionInD;
public SqlConnection ConnectionForD
{
get
{
return _sharedConnectionInD;
}
set
{
_sharedConnectionInD = value;
}
}
public void DoStuff()
{
_sharedConnectionInD.Open();
}
}
Simon
|
|
|
|
|
public class X
{
public readonly SqlCommand Command ;
public X
(
string ConnectionString
)
{
Command = ( new SqlConnection ( ConnectionString ) ).CreateCommand() ;
return ;
}
}
There, that wasn't so hard was it? (You can get the Connection from the Command.)
I would not leave the connection open constantly.
See also this[^] outstanding article.
|
|
|
|
|
I want to ask if someone has already have an article or working algorithm where it can get all the combination possible in a given word.
Example: "ABCD"
possible combinations or arrangement without duplicates:
"ABCD"
"ABC"
"ABD"
"BCD"
"AB"
"AC"
"AD"
"BC"
"CA" <--- is the same as "AC"
"CBA" <--- is the same as "ABC" or "BCA"
"BD"
|
|
|
|
|
You could do it recursively.
All combinations of "ABCD" can be calculated as
"A",
and all combinations of "BCD",
and all combinations of "BCD" with an "A" added at the beginning.
All combinations of "BCD" is:
"B"
and all combinations of "CD"
and all combinations of "CD" with a B added at the beginning
All combinations of "CD" is:
"C"
and all combinations of "D"
and all combinations of "D" with a C added at the beginning.
All combinations of "D" is:
"D"
Pass back up.
All combinations of "CD" is:
"C" and "D" and "CD".
Pass back up.
All combinations of "BCD" is:
"B" and "C" and "D" and "CD" and "BC" and "BD" and "BCD".
Pass back up.
all Combinations of "ABCD" is:
"A" and "B" and "C" and "D" and "CD" and "BC" and "BD" and "BCD" and "AB" and "AC" and "AD" and "ACD" and "ABC" and "ABD" and "ABCD".
And there is your answer:
"A"
"B"
"C"
"D"
"AB"
"AC"
"AD"
"BC"
"BD"
"CD"
"ABC"
"ABD"
"ACD"
"BCD"
"ABCD"
Of course recursion probably isn't the best way. It would be easier with a for loop, but everyone knows recursion is more fun.
Simon
|
|
|
|
|
That is easy by using recursion. Combine each letter with all combinations of the letters after it:
All combinations in "ABCD" is:
Combine "A" with each of all combinations in "BCD".
Combine "A" with each of the letters in "BCD".
Combine "B" with each of all combinations in "CD".
Combine "B" with each of the letters in "CD".
Combine "C" with each of the letters in "D".
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Where's the problem? I have thre listboxes. For example, the first one has 23 image paths, the second one has 7 imagepaths. First i check if any of them are the same then i add them to the third lsitbox. Then i want to create pictureboxes depending of the number of items in the third listbox.
Here's the code of the function:
void prikaz(int stevilo)<br />
{<br />
PictureBox[] picBOX = new PictureBox[stevilo];<br />
CheckBox[] chkBOX = new CheckBox[stevilo];<br />
<br />
for(int i = 0; i<lb1.items.count;> {<br />
Image a;<br />
Image b;<br />
<br />
a = System.Drawing.Image.FromFile(@txtNacrti.Text + @"\" + lb1.Items[i].ToString());<br />
<br />
picBOX[i] = new PictureBox();<br />
picBOX[i].Size = new Size(100, 100);<br />
picBOX[i].Name = "picc" + i.ToString();<br />
picBOX[i].Location = new System.Drawing.Point(picX, picY);<br />
picBOX[i].BorderStyle = BorderStyle.FixedSingle;<br />
picBOX[i].ImageLocation = @txtNacrti.Text + @"\" + lb1.Items[i].ToString();<br />
<br />
chkBOX[i] = new CheckBox();<br />
chkBOX[i].AutoSize = true;<br />
chkBOX[i].Name = "chk" + i.ToString();<br />
chkBOX[i].Location = new System.Drawing.Point(chkX, chkY);<br />
chkBOX[i].Text = lb1.Items[i].ToString();<br />
<br />
chkY = chkY + 106;<br />
picY = picY + 106;<br />
}<br />
}
Regards,
Matjaž
modified on Thursday, November 27, 2008 8:17 AM
|
|
|
|
|
Matjaž Grahek wrote: Where's the problem?
Yes, can you please tell us what the problem is?
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Nothing happens, thats the problem.
Regards,
Matjaž
|
|
|
|
|
You are creating Controls, but I do not see you adding them to any container.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Hmm... how does that go?
Regards,
Matjaž
|
|
|
|
|
me.controls.add('yourcontrol')
or if in panel
panelname.controls.add('yourcontrol')
or ...
any container control should have the controls methode use that to add them
|
|
|
|
|
yeah OR this.Controls.Add(control)
Thanks to u too
Regards,
Matjaž
|
|
|
|
|
OK, Just got it Thanks!
Regards,
Matjaž
|
|
|
|
|
When this is all the code that runs, then the controls won't belong to any parent (form or group box or something) - and consequently will not show up on the screen, since they are not part of any container control. There must be something like Form.Controls.Add(pic/checkBox[i]) for every control.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
I need to find all the visible windows of an other application or childs windows of a window extern to my application.
I'm not a native api expert , i searched a few but it's not an easy task because the 'window' keyword is too generic and procuces a lot of results.
Can someone put me on the right way please?
|
|
|
|
|
|
I read articles on Reflection still can't figure out a practical use for it?
Why dynamical invocation? I can see many practical application for "late-binding"/polymorphism but reflection ...
Perhaps NUnit? Test fixtures are not know until at runtime user specify dll to test... is NUnit built using reflection? Can somebody gives more practical application of reflection?
Thanks
dev
|
|
|
|
|
Plugins. Scripting. Dynamically binding to different versions of libraries.
I recently wrote a bunch of wrapper classes that used reflection to load a library assembly and call methods. It would try to load several different versions of the assembly in preference order.
Simon
|
|
|
|
|
most apps I seen before dont need to load dll dynamically... so I can't really quote another example of practical use except NUnit
that said, attributed programming (declare webmethod for instance) relies on reflection - but could that not be done with inheritance? (but say C# only allows single inheritance)
dev
|
|
|
|
|
Just because most apps don't use it doesn't mean that it's not useful.
Yes, I'd agree about 90% of the stuff I write doesn't use reflection at all. There are some things however that reflection is useful for. Plugins is a common example where dynamically loading assemblies is often used.
Simon
|
|
|
|