|
Dear sir,
What is the safty and the easy way for the right sequance steps to connect to the sql DB and open it and close it without any problems ad how can i in a programmatical way to avoid the logic & physical error
Thanks for all
Wael El Assal
Indystry data analyst
DSD-Ferrometalco
|
|
|
|
|
Create a connection object for the connection type you use, like an OleDbConnection object.
Put the connection string in the call to the constructor.
Create a command object for the connection type, like an OleDbCommand object.
Set the CommandText and CommandType properties.
Add parameter objects to the command object for any parameters you use in the query.
Open the connection.
Run the query using the method in the command object that fits what you want to do.
Dispose of the command object.
Dispose of the connection object. (This will automatically close the connection.)
---
b { font-weight: normal; }
|
|
|
|
|
Like this:
public void Foo(string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString) )
{
}
}
"God doesn't play dice" - Albert Einstein
"God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr
|
|
|
|
|
dear All,
Thanks for your quick replay,
My application designed to be distributed app. on a network & 30 users & sql server DB & C#.net I put the DB on the (server Pc.
this is the first time using C# tool so,please advice which kind of provider sugest to use SQl, Oledb, Odbc,...) which make the connection and the perfomance is very smothly on the network.
Thanks for this kindly help
Wael Elassa
|
|
|
|
|
we have a very huge distributed system and we make a lot of updates, a lot of bugs fixing and a lot of adding new features so I want to know if there is a versioning method rather than Assembly version to keep track with the system versions (major, minor, SPs) for every change and every update we made
Please any one know or have any paper talking about this subject, please inform me asap
|
|
|
|
|
Aloha,
We would like to make some nice controls based on the classic ASP.NET webcontrols. In order to secure that this is done probably, we would like to define an interface which defines the following:
interface IControl<br />
{<br />
void OnInit(EventArgs e);<br />
<br />
void Render(HtmlTextWriter output);<br />
<br />
string HeaderText<br />
{<br />
get;<br />
set;<br />
}<br />
}
The interface definitions of OnInit() and Render() are supposed to remind the coder that he should override the methods in the ASP.NET webcontrol. The problem is that these methods are protected and we therefore get the following error:
'MyButton' does not implement interface member 'IControl.OnInit(System.EventArgs)'. 'MyButton.OnInit(System.EventArgs)' is either static, not public, or has the wrong return type.
The HeaderText property works perfectly, but that is because it is implemented as public in the MyButton class.
Any ideas? If possible, we would love to be able to define protected methods in our interface... and if not possible, we would love to hear about another way of forcing the coders to implement everything.
Thanks, Mads
|
|
|
|
|
|
Thanks for your reply.
We can't make the methods public since their are defined as protected in the ASP.NET controls that we inherit from (no change of access allowed when overriding base methods).
Also, we cannot use protected abstract since C# doesn't allow multiple inheritance (we already inherit from the control we want to extend).
"private explicit interface implementations" doesn't allow us to change access to a method, it still have to be the same as for the base class - so this is also a no go
// Mads
|
|
|
|
|
|
Override the methods with a method that throws an (informative) exception. That way the coder have to override also.
---
b { font-weight: normal; }
|
|
|
|
|
How would you do that? When don't have a "middle" class where we can do the overriding.
Each of our control classes derive directly from a webcontrol - I think adding a class between the webcontrol and our class would be the same as doing most of the work ourselves
|
|
|
|
|
Then you can't do it. You cannot change the behaviour of a class using interfaces, you can only specify behaviour to be added. To change the behaviour of a class you need to inherit it.
---
b { font-weight: normal; }
|
|
|
|
|
We don't want to change the behaviour - we just want to make sure that some protected methods are overriden in the classes that inehrit from the base class.
Thanks for your help.
|
|
|
|
|
You just can't do that without changing the behaviour. If the base class doesn't enfoce that the methods are overridden, you can't enforce that without changing the methods.
---
b { font-weight: normal; }
|
|
|
|
|
Dear All,
Does anyone know how can I zoom and image in and out..and make it initially when displayed fit the area specified for it without having to use scroll bars?
Thanks and Best Regards,
E.A.
|
|
|
|
|
Hello
Using DrawImage method of Graphics class you can specify any size for your image. And it will be drawn using that size.
With best regards,
Andrew
|
|
|
|
|
Got problem as follows:
In the main form I have 100 PictureBoxes which names are digit00...digit99.
I need to change their images often that`s why I would like to group them into some structure, an array for example. Then write a function that would cover this automatically, for example:
<br />
void MyFunction(int which)<br />
{<br />
MyArray[which].Image = Image.FromFile("aaa.aaa");<br />
}<br />
How to do this, especially how todefine and set the array?
tnx a lot in advance
|
|
|
|
|
Hi,
I think one option could be to use an ArrayList (something like a dynamic array) or another one to use a hashtable, where you use the name of the picturebox as key and the picturebox itself as value.
What are you looking for exactly ?
Regards
Sebastian
|
|
|
|
|
Hey,
Firstly I'm using VS 2005 Beta2.
I'm using databinding to a combobox which is populated with user defined objects (of the same type), and the databinding is on the it's SelectedItem property.
<br />
Binding bOnX = new Binding("SelectedItem", myDataSource, "objX");<br />
<br />
bOnX.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;<br />
<br />
comboBox.DataBindings.Add(bOnX);<br />
Now I know by default the databinding is onValidation hence I've changed it to OnPropertyChanged. However, it still does not bind to the data source when I changed the selected item, only when I move focus to another control. With that said, I'm also using the same DataSourceUpdateMode for a text box with a databinding on it's Text property and that works every time the text changes in the TextBox.
I think (please correct me if I'm wrong) that the OnPropertyChanged on works on the the property being bound to, for eg.:
for,
Binding bOnX = new Binding("Text", myDataSource, "strX");
DataSourceUpdateMode.OnPropertyChanged, works on the TextChanged event
but because there is no SelectedItemChanged event it does not work on the former example.
Can anyone please let me know if I'm right or wrong, and either way, please suggest a solution.
chukkykzn
chukkykzn@msn.com
|
|
|
|
|
Hi,
I'm looking for a way to change the default height of the propertygrid description pane.
The only property we have from the Propertygrid object is HelpVisible, but not any which could set its height.
I looked inside the object, and the PropertyGridInternal.DocComment object is the description pane object, but it is private and its impossible to access to its properties (like Height...).
I also tried to derive the propertygrid object and access to its child controls, but it does not change anything :
class MyPropertyGrid : System.Windows.Forms.PropertyGrid
{
public MyPropertyGrid
{
}
public void ChangeHeight()
{
foreach(Control ctl in this.Controls)
{
if(ctl.Text == "Description Pane")
ctl.Height = 100;
}
}
}
It might possible, because the PropertyGrid of the object properties in Visual Studio does remember the height of the description pane (try to change it, close VS, reopen it and see!).
Thanks in advance,
Touffic
|
|
|
|
|
hi,
Our marketing team wants to release a product that should run only run on the computer of the user for an X amount of days, after that it should just show some messagebox. Kind of like a time trial version.
Now my question is, how can I make this as tamper proof as possible, since people can still put their windows clock 1 year back, and keep working with the program.
Any hints and/or tips where I should look at?
thanks,
Gidon
|
|
|
|
|
Hi...
just a small suggestion... maybe you can build your application to do a date check upon every execution... as long as there is a difference between this captured date and the saved date... increase your counter by the difference (x) ... take it as the application has been running for x numbers of days... then save this new date... thus even if i were to set the date back 1 week... the program will acknowledge this as the program being used for 1 week...
thus when the counter reaches, say 30... the trial period will end... make sure to encrypt the counter value...
there is a way to tamper though... that would be for the user to set the date to the same as the first launch date everytime before starting the program... or they found a way to tamper with your counter value...
just a suggestion...
|
|
|
|
|
Hello friends!
I'm in the process of conceptualizing a test program that (hopefully) shuts down my unit for a given time but the catch is I want the program to close all running applications first particularly my internet connection (since i'm using dial-up connection) and shuts down my unit properly. Is this do-able in c# and if so could someone please give me a boost on this.
I'm fairly new to programming let alone c# and i'm trying to scroll through the namespaces and i can't seem to get a solution for my problem. So any assistance regarding this matter would mean gold to me. Thanx for all your helps!
Oh yeah I'm using Windows XP home ed and VS.NET 2003. Almost forgot..
Kampai!!!
|
|
|
|
|
you can try using kill() to kill the processes
you can try searching msdn for "C# kill process"
|
|
|
|
|
Hey thanx!
I found a similar program that shuts down a machine for a give time but the problem is it forces applications to terminate meaning it doesn't close applications properly. Any lead on this? How can i access my tool bar using c#? Thanx!
Kampai!!!
|
|
|
|