|
No you don't, that won't happen, and the user probably wouldn't want it to happen anyway.
The user may already have SQL Server installed (perhaps a full version), on this machine or another. Or the user may want to install your software after a newer version of SQL Server is released.
Just state in the documentation that SQL Server is required and that it's up to the user to ensure that it is available.
Perhaps include a link to the Express download for users who don't already have it installed.
|
|
|
|
|
i need something like MSDE that we have for sql server 2000. in which user just click once. User don't know which options should be selected and he will just install the application and my msi package will include both of these. but when it will run the setup for sql express it require the options to be selected. but if the user is a common person and does not know more about computer then he will just require me to provide a once click setup.
|
|
|
|
|
WaseemAmin wrote: if the user is a common person
That's a big if. Better not assume your users are idiots.
Additionally, SQL Server CE[^] may be a better fit.
|
|
|
|
|
Although I'm still a newbie, I think I can safely say I'm an intermediate newbie probably really close of crossing the threshold of an advanced newbie…
I understand most things about inheritance, encapsulation, constructors, methods and parameters, properties, accessors and access modifiers (keep in mind I said, "most things")…
I know I still have a long way to go, but…
readonly
Was this created as some sort of safety and precautionary practice?
If we don't want something to change, we can use:
const
Or properties utilizing
protected or even
private
.Net I realize is always evolving, because of this… Is this the reason for the "readonly" keyword?
|
|
|
|
|
There's a subtle difference between readonly and const which it sort of emulates. If you like, you can think of readonly as a runtime constant as opposed to const which is a compile time constant. What does this mean? Well, a readonly field can be set in a constructor, so the value that is held in the readonly field is made constant once the class is initialised, as opposed to const where it's constant from the start. In other words, you can change the value in a readonly field at runtime, but you can't with a const field. A practical example might help. The first class defines the ANSWER, which can never change.
public class H2G2
{
private const int Answer = 42;
public H2G2()
{
Console.WriteLine("The answer to Life, the Universe, Everything is {0}", Answer);
}
} A couple of things to notice in this example. The first is that you can't change the value of Answer while the application is running. The second thing (unsaid), is that you can't make the const static. Okay, now here's a version of readonly.
public class TaxCalc
{
private readonly double taxRate;
public TaxCalc(double taxRate)
{
this.taxRate = taxRate;
}
public void Calculate(double value)
{
double total = value * taxRate;
Console.WriteLine("The total is {0}", total);
}
}
|
|
|
|
|
Pete O'Hanlon wrote: There's a subtle difference between readonly and const which it sort of emulates. If you like, you can think of readonly as a runtime constant as opposed to const which is a compile time constant.
Would that also mean, like a struct… Once it goes out of scope, it gets destroyed?
|
|
|
|
|
Yes. It exists per instance, so once the instance is out of scope, the readonly is out of scope.
|
|
|
|
|
|
readonly exists solely to prevent anyone from, either accidentally or intentionally, changing the value of a variable once it's set.
It is enforced at run-time.
|
|
|
|
|
In addition to the answers you have already been given, you can't create const s of your own class es/struct s but you can create static readonly instances which are commonly used to serve much the same purpose.
|
|
|
|
|
hi there
i have an issue
i have a record that is moving next each time timer interval started >>> also i have a delay button that it must delay a specific record for an interval let say(2 min)
after two minutes its displayed the rest of records in datetable
my idea is >>>
when delay button clicked i move the current record to another datatabbe and after 2 min i restore it back to the original datatable but unfortunately i get an error
"that deleted records cant be inserted " ? even if i refreshed my datasource
not i am using timers
can some one help or give me another idea or a solution
here is my code
delay button
<pre lang="cs">int x;
x = Convert.ToInt16(pationt_noLabel1.Text);
var rows = dt.Select("pationt_no=" + x);
foreach (var r in rows)
{
delayed.ImportRow(r);
r.Delete();
}
var rowss=delayed.Select("pationt_no="+x);
foreach (var row in rowss)
{
row["test_time"] = DateTime.Now.ToString("hh:mm");
}
testsBindingSource.DataSource = dt;
testsBindingSource.MoveNext();
and my delay method
testsBindingSource.EndEdit();
string time1s = DateTime.Now.ToString("hh:mm");
if(delayed.Rows.Count==0)
return;
else
foreach (DataRow dr in delayed.Rows)
{
string time2s = dr["test_time"].ToString();
TimeSpan interval = DateTime.Parse(time2s).AddMinutes(delay_time) - DateTime.Parse(time1s);
double tot=interval.TotalMinutes;
if (tot >= 0)
{
dt.ImportRow(dr);
testsBindingSource.DataSource = dt;
dr.Delete();
MessageBox.Show(dt.Rows.Count.ToString());
}
else
{
}
}
and timer tick
testsBindingSource.DataSource = dt;
get_printed_tests(dt);
is_delayed(2);
|
|
|
|
|
eng.iris wrote: when delay button clicked i move the current record to another datatabbe and after 2 min i restore it back to the original datatable Wait, what?
I don't know what "status" you deduce from the record being in the one or the other table, but a bit-flag at the end of the record would be more appropriate. When it should be in the table, clear the flag of the record, and set the flag when you "would" copy it to some different table.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanx alot for your answer
Eddy Vluggen wrote: Wait, what?
may be my idea was not good
i dont get ur idea >>> having a flag in the datatable? and the columns have fixed count ?
|
|
|
|
|
eng.iris wrote: may be my idea was not good It was, it's just an unusual design, that has some things that might not be optimal.
I'll be posting more explanation tommorrow or over the weekend.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
eng.iris wrote: i dont get ur idea "Your" idea; we don't do textspeak here. I've recreated a simplification of your tables below, and you said that you'd be moving a record from table A to table B, when a timer-event occurs.
CREATE TABLE A (
pationt_no BIGINT
pationt_name VARCHAR(250)
test_time DATETIME)
CREATE TABLE B (
pationt_no BIGINT
pationt_name VARCHAR(250)
test_time DATETIME) You could remove table B from the design, simply by adding a flag (a boolean/bit field) to table A;
CREATE TABLE A (
pationt_no BIGINT
pationt_name VARCHAR(250)
test_time DATETIME
IsInTableB BIT) Whenever you'd want all records that are in A, but not in B, you'd extend the WHERE clause with a filter for the IsInTableB column, like below;
SELECT *
FROM A
WHERE IsInTableB = False
eng.iris wrote: when delay button clicked i move the current record to another datatabbe and after 2 min i restore it back to the original datatable but unfortunately i get an error
"that deleted records cant be inserted " ? even if i refreshed my datasource That datatable is an in-memory representation of the real table. I'd recommend using SQL-statements to update the physical table in the database - that way the information doesn't get lost when the application or the power fails.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hi everybody
i have a HD USB satellite card and i wiant my winform app to show tv and my records
is there a tool to show them ?
is there an activex ?
i am new in this field
somebody can help
its urgent
thanx alot
|
|
|
|
|
|
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
Okay, I understand that you can use the same variable when declaring the fields… Reference Variables, right?
My book goes on to say, "It is obvious that the keyword this cannot be used with static constructors or fields."…
I'm not sure what they are saying about not using the keyword "this" on static constructors or fields…
I know when you use the "static" keyword on a member/field it then belongs to the class it was declared in and when you create a static class that all members/fields/methods/properties must also be declared static…
For some reason I'm not making the connection on why you cannot use "this" keyword on static constructors or fields.
|
|
|
|
|
Look at it this way:
"this" refers to the current instance of this class that the code is running in.
Static classes do not have an "instance" (aka they are not created with the "new" operator), so therefore it does not make any sense to refer to members using the "this" keyword.
|
|
|
|
|
So, when you're using "this" keyword… It is kind of a shortcut method, instead of having to type out a whole new instance statement?
|
|
|
|
|
No, I guess its a little difficult to understand...
Every time you use the "new" operator you create an instance of the class. Think of a class as how an object behaves or can be interacted with in memory. Until you create an instance of it (for instance classes), you can't interact with it. Static methods do not get instantiated with the new operator, so they are not instance classes.
Sometimes you need to interact (internally) with the current instance of the class, that's when you use the "this" keyword.
For example, if you have:
public class Point
{
int x;
int y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
}
In the above, you need a way to differentiate between the x member of the class, and the x parameter of the method. You can do this with the "this" keyword, which says "set the member x of this instance of the class to x (the parameter of the method).
You still instantiate it with something like:
Point p = new Point(5,10);
this is only used internally in classes, the "this" keyword can only refer to the current instance of the class that you are in.
|
|
|
|
|
this Always points/refers to a member/field?
|
|
|
|
|
this is simply a reference to the current instance of the class, you use the '.' operator to refer to any member/field/method inside the current instance of the class.
Just like outside the class you use the variable name and the "." operator to interact with the class, inside the class you can use the "this" to interact with the class.
|
|
|
|
|
There is no instance associated with a static keyword. Thus using this makes no sense.
|
|
|
|
|
a class can be seen as a template to create objects with. Your class Car eg can have multiple instances like this:
Car lamborghini = new Car();
Car ferrari = new Car():
if you declare a normal variabel like color eg. you can assign a different color to each instance you created.
Car lamborghini = new Car("pitch black");
Car ferrari = new Car("pomegranate red"):
lamborghini.color = "Le Mans blue";
ferrari.color = "Purple";
However, if you assign a static variabel (or function) you cannot assign it to one or the other object. Suppose we assign a static variabel type to car and give it the value "vehicle", neither the lamborghini nor ferrari object has that value, it´s the class Car that has that value. That´s why you access it like this:
String cartype = Car.type;
static members are attached to the class, not to the instance of that class. this points the its own instance.
Hope this helps.
(PS: I want against OO rules here to simplify things, but don´t go making things public like that )
|
|
|
|