|
Hei All,
Can we install any big software via C# setup application? I want to install SQL Server before my application and then create user in sql server but I dont know how can i install SQL server via setup file?
Thanks
Syed Shahid Hussain
|
|
|
|
|
|
Hei Thatraja,
Thanks u so so so so much. You dont know how big treasure u have given to me.
I'm Happy Thanks once again.
Syed Shahid Hussain
|
|
|
|
|
Best practice is that you don't do this. SQL Server is only supported as a seperate install.
Once the server is installed and running seperately, your application installer can be told which SQL Server to use and what the login credentials should be to execute a SQL script to add your users and setup the database and its security.
|
|
|
|
|
Thanks for ur reply.
I'll read the setup process completely and keep in mind ur points while developing setup project.
Syed Shahid Hussain
|
|
|
|
|
Simple answer is yes.
But, what the hell do you want to install?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Hello all,
I have two questions.
1) I have labels and textbox.
For ex;
lblName1.Text = txtName.Text;
lblName2.Text = txtName.Text;
lblName3.Text = txtName.Text;
lblName4.Text = txtName.Text;
Is there a way that i can do that in a loop something like:
for(i=0; i<4; i++)
{
lblName[i].Text = txtName.Text; // of course it does not accept [i]
}
2) How can I find a certain type of a contol in a webform and change the controls property.
Ex; I have 10 checkboxes. without coding one by one. Is there a way that I can assign its check selected to false more proper way ;
cb1.Checked = false;
cb2.Checked = false;
cb3.Checked = false;
.
.
cb10.Checked = false;
Thanks.
modified on Friday, March 11, 2011 1:30 PM
|
|
|
|
|
1) You can do it - sort of - with reflection, but it is one heck of a sledgehammer to crap a simple nut. What you end up with will be longer than the code to do it directly, and a lot harder to read and understand.
If you really want to access a number of controls in a loop, can I suggest the simpler, elegant way of having a class level list of labels?
List<Label>myLabels = new List<Label>();
...
myLabels.Add(lblName1);
myLabels.Add(lblName2);
myLabels.Add(lblName3);
myLabels.Add(lblName4);
...
foreach (Label lab in myLabels)
{
lab.Text = txtName.Text;
}
2) Not sure what you mean here: are you trying to do the same as in (1) but for CheckBox? If so, then the same answer applies. If not, then what are you trying to do?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Well actually I mislead you on the first one it was like;
lblName1.Text = txtName.Text;
lblName2.Text = txtName.Text;
lblSurname1.Text = txtSurname.Text;
lblSurname2.Text = txtSurname.Text;
so seems like it is better for me to code it directly.
for the second one; after evaluating your answer, it seems like the solution for the second is the same with Q 1
|
|
|
|
|
Anyway, even though you've apparently changed what you need to do, what you originaly asked for *is* possible, relatively easily done, and only moderately dangerous.
for (int i = 0; i < 4; i++)
{
(FindControl("lblName" + i.ToString()) as Label).Text = txtName.Text;
}
Pretty sure, anyway.
|
|
|
|
|
Actually yeah that is what I tried to mean. That should do it thanks anyway though but why is it dangerous?
I am guessing ;
During looping, when cant find a matching label name, it will throw an exception?
|
|
|
|
|
Yep. There had better be controls to match the loop variable number, or ka-boom!
Also: if, for whatever reason, you ever need the controlks to be set in a certain order...don't count on it. The compiler will do the loop in whichever order it feels is best.
|
|
|
|
|
Not tested, however I expect this should suffice:
for (int i = 0; i < 4; i++) FindControl("lblName" + i).Text = txtName.Text;
as each Control has a Text property, so no need to cast; and ToString() is implicit when appending to a string.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc Pattyn wrote: as each Control has a Text property, so no need to cast
It won't compile.
'System.Web.UI.Control' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'System.Web.UI.Control' could be found (are you missing a using directive or an assembly reference?)
Or is there a switch somewhere to "relax" this?
|
|
|
|
|
I wrote: as each Control has a Text property
Sorry, that was wrong. While true for WinForms, it ain't true for System.Web.UI so the cast is required!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Regarding 2), I would think you could put something like this in the code behind:
foreach ( Control c in this.Controls )
{
if ( c is CheckBox )
{
( ( CheckBox )c ).Checked = false;
}
}
Jack of all trades ~ Master of none.
|
|
|
|
|
Hve you consodered For Each TextBox ?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
No no.
1. For Each is VB, not C#
2. Form.Controls holds all top-level Controls of the Form, no matter what type they are; if one of them isn't a TextBox, foreach will fail to cast it and throw an exception, it does not enumerate just the derived type one is interested in!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
hi All, I am having trouble doing some string manipulation. I get a string with coma delimited. I want remove the first portion of the string.
for example,strMessage = " I, Have, a, string, that, describe, something"
what I want to do is that remove the first coma delimited part of the variable strMessage so it look like this
"Have, a, string, that, describe, something" how do I do this. Any help appreciated.
then I insert the string in my datagridview.
datagridview.Rows.Insert(0,strMessage.Split(','))
I want to keep this style of inserting into dataGridView just want to remove the first portion of the string which is "I".
thanks
|
|
|
|
|
string.Split() is the method you want; it has a few overloads, so I refer to its documentation.
BTW: you won't solve problems any faster by putting as much as possible into a single statement. Split things up, and look at the intermediate values while debugging.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
this is quite simple for the case you stated. That is just the first comma.
Use IndexOf. Something like:
str.Substring(str.IndexOf(",") + 1).TrimStart();
All the best,
Dan
|
|
|
|
|
Here[^] is the solution to all your problems.
(Well the ones about splitting, personal probelms are chargeable).
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
string[] parts = strMessage.Split(",");
for (int i = 0; i < parts.Length; i++)
{
parts[i] = parts[i].Trim();
}
dataGridView.Rows.Insert(0, parts);
But don't you need to ensure that the number of parts matches the number of columns you have in the row?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hi,
I generate an Xml File with XmlTextwriter.I saved it in a known path (C:\Documents and Settings\My Documents\Visual Studio 2008myprojects\MyFile.xml). I want now to let the user choose where he wants to save his xml File.
How can I import the data from my xml File to copy them in the specified file choosen by the user of my application????
Thank u very much
modified on Friday, March 11, 2011 5:33 AM
|
|
|
|
|
Good question.
Here is how i did. Suppose user selects the path like this :
Path="C:\MyFile.xml";
Suppose you have an object of xmlDoc containing the xml.
So now we have to create a Filestream for the new path, and then use the StreamWriter class to write the xml to the new path.
FileStream fs=new FileStream(path,FileMode.Create,FileAccess.ReadWrite);
StreamWriter sw=new StreamWriter(fs,Text.Encoding.UTF8);
sw.Write(xmlDoc.OuterXml);
sw.Close();
fs.Close();
Hope it helped!
People with high attitude deserve the standing ovation of our highest finger!
My Technical Blog![ ^]
|
|
|
|