|
Yes but how do I keep it generic untill the last minute?
I have tried
public Access[] findAll()<br />
{<br />
string sql = "SELECT * FROM access";<br />
<br />
LinkedList<T> list = executeSQL(sql);
<br />
Access[] aArray = new Access[list.Count];<br />
list.CopyTo(aArray, 0);<br />
<br />
return aArray;<br />
}<br />
<br />
public LinkedList<T> executeSQL( string sql, string [] array )<br />
{<br />
LinkedList<T> list = null;<br />
<br />
try{<br />
<br />
...<br />
<br />
return list;<br />
}
but that does not work
|
|
|
|
|
Hello Friends,
I have made a Web Service and am using its reference in a Window Service that is being executed/called every 1 min. Through the Web Service, I am connecting to a remote MySQL Server database in which some of the table are accessed and data is being inserted/updated into them.
As the current window service is still in development phase, so whenever i install the batch file of the window service every other day, just in order to check that whether the whole process is running fine or not, The web-service throws an error:-"Unable to connect to server". This error comes only when the web-service is unable to connect to the remote server .
But the moment i rebuild the web-service at my my machine and then update (replace) it on the web-server and again add it as a reference to the window service then after rebuilding the window service when i run the batch installation file of window service; the whole process executes absolutely fine and the web-server database tables gets updated.
I am not able to sort out why an unusual behavior is being shown by web service. Please help me out.
Thanks
Varun Sareen
|
|
|
|
|
I believe your webservice reference includes the IP (is pointing directly) to the remote server.
This is probably what is creating the problem.
Remove this reference by changing your code to point to a dynamic IP and things should be fine.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Thanks dear Abhinav for providing such clarity but are you talking about:-
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053");
the italicized text or the Server address in the connection string.?
<add key ="ConnectionString" value="Server="ip address"; Uid="userId"; Pwd="password"; Host="hostname"; Port=3306; Database="dbName"; Compress=false; Pooling=true; Min Pool Size=0; Max Pool Size=100; Connection Lifetime=0;"/>
Thanks
Varun Sareen
|
|
|
|
|
Er no I was not talking about the connection string.
Have a look at the configuration file that includes the IP address you need to point to.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
|
Hi,I am able to draw rectangles on the picture but I am not able to capture the co-ordinates of the picture box instead it capture the screen coordinates.So the rectangle that I draw on the picture box doesn't appear on the position that I desire.
private void MyDrawReversibleRectangle(Point p1, Point p2)
{
Rectangle rc = new Rectangle();
p1 = this.pictureBox1.PointToScreen (p1);
p2 = this.pictureBox1.PointToScreen (p2);
if (p1.X < p2.X)
{
rc.X = p1.X;
rc.Width = p2.X - p1.X;
}
else
{
rc.X = p2.X;
rc.Width = p1.X - p2.X;
}
if (p1.Y < p2.Y)
{
rc.Y = p1.Y;
rc.Height = p2.Y - p1.Y;
}
else
{
rc.Y = p2.Y;
rc.Height = p1.Y - p2.Y;
}
textBox1.Text = Convert.ToString(rc.X);
textBox2.Text = Convert.ToString(rc.Y);
textBox3.Text = Convert.ToString(rc.Width);
textBox4.Text = Convert.ToString(rc.Height);
ControlPaint.DrawReversibleFrame(rc,
Color.Black, FrameStyle.Thick);
}
private void button1_Click(object sender, EventArgs e)
{
motionDetector = new MotionDetector(simpleBackgroundModeling, blobCounting);
int x = Convert.ToInt32 (textBox1.Text);
int y = Convert.ToInt32(textBox2.Text);
int width = Convert.ToInt32(textBox3.Text);
int height = Convert.ToInt32(textBox4.Text);
bflag = true;
rectangle[1] = new Rectangle(x, y, width, height);<pre lang="cs">
|
|
|
|
|
I am not getting your question properly
but I suppose you have to use MouseDown, MouseUp even to capture X, Y Point
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
I think you are looking for the
PointToClient method. It's implemented on Control so just use:
pictureBox1.PointToClient()
E.g. If you want to convert the current mouse position to Control coordinates use.
Point ptControl = control.PointToClient(MousePosition);
|
|
|
|
|
I'm using the following code to back up a SQL Database :
void BackupDatabase(string sConnect, string dbName, string backUpPath)
{
using (SqlConnection cnn = new SqlConnection(sConnect))
{
cnn.Open();
dbName = cnn.Database.ToString();
ServerConnection sc = new ServerConnection(cnn);
Server sv = new Server(sc);
BackupDeviceItem bdi = new BackupDeviceItem(backUpPath, DeviceType.File);
Microsoft.SqlServer.Management.Smo.Backup bk = new Backup();
bk.PercentComplete += new PercentCompleteEventHandler(percentComplete);
bk.Devices.Add(bdi);
bk.Action = BackupActionType.Database;
bk.PercentCompleteNotification = 1;
bk.BackupSetDescription = dbName;
bk.BackupSetName = dbName;
bk.Database = dbName;
bk.LogTruncation = BackupTruncateLogType.Truncate;
bk.FormatMedia = false;
bk.Initialize = true;
bk.Checksum = true;
bk.ContinueAfterError = true;
bk.Incremental = false;
bk.SqlBackup(sv);
}
}
In my system (Win7 x64) it works fine but in destination system (WinXP SP3 x86) I receive the below error :
Exception[^]
How can I fix it ?
Thanks.
BTW:
I installed SQL Express 2008 R2 in destination system.
|
|
|
|
|
Is the version of .NET on the XP system the same as that on your Win7 system? If not, you may want to try to build against a lower version if possible.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: Is the version of .NET on the XP system the same as that on your Win7 system?
The version that I've created the code based on was 9 but the version of destination system is 10, I created the project with 10 version but I receive below Exception :
Restore failed for Server '\\\\.\\pipe\\3F103E6E-3FD4-47\\tsql\\query'.
|
|
|
|
|
A simple Google action yields this[^].
|
|
|
|
|
Hello.
I need to look after a number of elements in the periodic chemistry, with their values, eg:
Na = 23
O = 16
H = 1
etc.
I will have an input box, where someone could input a molecular structure using a formula, for example.
NaOH
My program would then total the individual atomic values for that structure, so the above would be 40.
My question is, should I store my periodic table like the following:
const int Na = 23
const int O = 16
etc
Or should I create an enum, or would there be a better method I have overlooked?
Thank you
Steve
|
|
|
|
|
I would use a set of constants, an enum is based on the position of the item in the enum rather than the value.
Or in an xlm file loaded into a List<> ot dictionary, at least then you have some functionality build in to your container.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You can force a value on an enum , this can be a very good way to keep related items together:
public enum MemberStatus
{
Any = 0xffff,
Contact = 0,
Associate = 1,
Waiting = 2,
Member = 4,
}
You can also combine this with Human readable strings for enum elements[^] which elevates it way above what you can do with a const value!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Mycroft Holmes wrote: an enum is based on the position of the item in the enum rather than the value
Ummm... what?
|
|
|
|
|
I suggest you put them all in a Dictionary<string, int> , so you can look them up by their symbol name.
Unless you will need more information for each element later on, then create a ChemicalElement class, and store them all in a Dictionary<string, ChemicalElement>
|
|
|
|
|
You just beat me to this solution, by 15 hours .
|
|
|
|
|
OK, thanks for the replys, all semm good so I will delve into this a little more and make my decision.
Thank you
Steve
|
|
|
|
|
An enumeration, liberally decorated with Attributes for additional information, and read it into one or more Dictionaries.
|
|
|
|
|
PIEBALDconsult wrote: An enumeration
Yes, thats what I was originaly thinking, as you can cast values, so I could have...
enum chemicalEliments { O = 16, H = 1 etc}
PIEBALDconsult wrote: liberally decorated with Attributes for additional information
Sorry, I do not know what this is?
PIEBALDconsult wrote: and read it into one or more Dictionaries
Again, not sure what this is, still new to c#.
Would using enum on its own not suffice for this relitivly small problem?
Thank you
Steve
|
|
|
|
|
Enumerations... an elegant weapon for a more civilized age.
Enum Utilities[^]
enum Elements
{
[Description("Hydrogen")]
H = 1
...
}
You could create your own Attributes to indicate valency* and such.
* Or whatever, it has been a long time since high school.
|
|
|
|
|
PIEBALDconsult wrote: Or whatever, it has been a long time since high school.
Well this is not a high school project, I am a Biomedical Scientist so a little more involved, but this has now given me a good starting point, so thank you.
Steve
|
|
|
|
|
In real life, I was a chemist - and although the several suggestions for an enum are a direct way to create your listing, I would look towards future use (which is likely to come, some day), where you'd maybe want to add the atomic no., valence, atomic wt., phase at STP, full name (viz-a-viz, symbol) and so on.
It's very little additional effort to prepare for these potentialities: create a data class, each element receiving its own instance. Declare a data member for each additional feature as you need them.
As for the container, the Dictionary is a good option for your original task, conversion of formulas into molecular weights. Note that using the data class allows you to store your initialization data for the table in a wide variety of formats: from hard coded to database.
An additional consideration: getting familiar with generalized solutions to a problem (extensible data class) will make good practice for solving general problems in the future. After all, how different is the periodic table data from a music library or phone book?
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek dissappointment. If you are searching for perfection in yourself, then you seek failure." - Balboos HaGadol Mar 2010 |
|
|
|
|