|
You would have to use interop and the Microsoft ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX) To do this, since MS Access sql syntax does not support "create database". IMO a better alternative is to just include a small empty database as a template, and use filecopy to create the starting database (faster, too...). If your schema is constant, you can even pre-build all empty tables and queries, saving a good deal of 'one time' code in your application.
Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
|
|
|
|
|
Yes, after reading the other replies I think that is much easier . Would it be possible to include this templated .mdb file as a resource in the app? Basically what I'm after is a single .exe file as the final result as this app would be copied rather than installed, and with the technical level of my clients, a single file is the easiest option.
|
|
|
|
|
I haven't tried that, but it should work. Just create a new empty file and then copy the resource bytes to it with a BinaryWriter..bytes is bytes
Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
|
|
|
|
|
Thanks, I'll give that a go
|
|
|
|
|
Let me point you to "Programming OLEDB with C#" - http://www.manning.com/dotnetbooks/csharpprimer/sql_to_access.html
|
|
|
|
|
like I said - one must use ADOX to create an access database programatically.
Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
|
|
|
|
|
My application must resolve dns name of host. Iam tryning
string HostName = System.Net.Dns.GetHostByAddress( "207.219.70.31" ).HostName<br />
its error
"An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: Configuration file E:\Baton\AnonMailer\bin\Debug\AnonMailer.exe.config does not have root <configuration> tag"
Im using Custom application configuration[^]
Thanks,
|
|
|
|
|
I want to make a class which automatically truncates text to a specified length. This is how I would like to use it while coding.
Text text = new Text(4);
text = "This text will be truncated to 4 characters.";
string truncated = text;
Truncated now should return a value of "This". Remember, this is a simplified example of what I want to do. I want to have a lot more properties and functionality than length.
Returning the value isn't a problem. I can write a conversion operator: public static implicit operator string(Text text).
But, after looking further into operator overloading I came to the conclusion that it is impossible to perform the truncation. I can never have access to the length, because operator overloading uses static functions.
I can think of several solutions to this problem but the code to use it is uncomfortable.
1. Using a new Text(...) each time. Too many properties and too much chance for errors. I really don't want to look up each time which values I need this time.
2. Since I was going to use Properties to access the Text class I could reapply all values in the set function. I could get the desired syntax but this leads to some really awful code. Plus, each time I would instantiate a new object I need to update the reference in two places.
3. Using a property in the text class: text.Data = "This ...". I guess this is the best solution although I really hate the syntax.
Can anybody come up with a good solution?
|
|
|
|
|
|
I'd completely agree with you if all that I wanted to do was just truncate a string.
Here's the thing that I want to accomplish: a DataSet is a great object to contain data, but it's a bit difficult to access. I would like to write a wrapper around it to access fields in a row straightforward and without casting. I want to have functions like NextRow and PreviousRow, ...
The fields (like Text) are going to read the data out of the DataSet. This is no problem at all. But when I want to place data in the Dataset I want to preprocess it before changing the dataset. Length was just one example. Another example could be making text uppercase for a key field or verifying that a number is between some values, or even more complex functions.
In C++ I could overload the assignment operator. I was just surprised that it wasn't possible in C#. I really do like the language and I'm determined to use it. I just have to find a decent workaround.
Basically, I'm trying to create an easily accessible and extendable framework to work with a lot of data. Over time there are going to be hundreds of tables. I'd rather do the extreme part early then later and since the project isn't even started I'm free to experiment and take my time without the pressure of a release date.
|
|
|
|
|
So why not just create a wrapper for the DataRow. In the past I have used code like this:
public class Person {
private DataRow theRow;
public Person(DataRow row) {
theRow = row;
}
public string Name {
get {
return (string)theRow["PNAME"]
}
set {
theRow["PNAME"] = value.Substring(0,40); // only stores 40 chars
}
}
public DateTime BirthDate {
get {
return Convert.ToDateTime(theRow["BDATE"])
}
set {
if (value > DateTime.Now) throw new Exception("Invalid date");
theRow["BDATE"]=value;
}
}
public override string ToString() {
return Name + " was born " + BirthDate.ToString("d");
}
}
Now you can write client code like this:
DataTable table = new DataTable("People");
// use ADO.NET/Xml to load table
foreach(DataRow row in table.Rows) {
Person p = new Person(row);
Console.WriteLine(p.ToString());
}
This is very similar to the code generated by XSD.exe. Though, I find writing the code yourself gives you a lot more control over the evolution of the class. You can add your own methods, throw exceptions when a property is set with an invalid value..etc..etc.
|
|
|
|
|
Thanks for the suggestion. I'll definitely consider it. The only thing that I don't really like is the fact that I have to program each field separately. You'll get total flexibility at a price.
|
|
|
|
|
How can I find out programmatically if there is a dial-up connection to the internet in C#? I've looked through the MSDN stuff but it's heavy goinga as I've done no internet coding before. All I need to be able to do is check for internet connections, and if there are any, then disconnect them.
Dave Kerr
focus_business@hotmail.com
www.focus.esmartweb.com
|
|
|
|
|
This might be a simple question to some but has caused me a few too many brain cells. I do not see any way possible to conditionally use an event. That is, in a standard class you can override the method and then if you choose, you can call the base class to execute that code. As a multicast event will call the handlers in order they where added, I can see no way to bail and revert to some default processing if certian conditions arise from within your handler.
Wondering if this has ever been an issue..
Rocky Moore
|
|
|
|
|
|
I'm making an IRC Bot for statictics and I need to launch it into the background(like eggdrop). This bot runs in linux with mono(Free .NET Implantation).
Does anybody has any clue about this?
Trully, if there evil in this world, It lies within the heard of mankind
Shock The Dark Mage
shock@romhack.net
Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
|
|
|
|
|
|
Thanks again leppie, but if you know how to program it in the program rather than using the &, let me know.
Trully, if there evil in this world, It lies within the heard of mankind
Shock The Dark Mage
shock@romhack.net
Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
|
|
|
|
|
In UNIX, in order to have the program put itself in the background, it needs to fork a child process. True system daemons are double-forked. The first fork puts the program in the background, the second fork isolates itself from the current process group (e.g., a user's session). However, Windows has never supported the concept of fork(), so it would be surprising to see it in .NET.
It appears that Mono is closely following the .NET SDK to make sure that Mono (.NET) programs are cross-platform, but in case there is a concept of fork() within Mono, go with that. For a 100% pure .NET cross-platform program, I'd suggest you take a peek at System.Diagnostics.Process.
|
|
|
|
|
I need to find a smaller string of characters inside a larger string, but have no idea how to go about it. I know there is the 'SubString' method, but that will not work in this case, as the sting i am looking for will be in different locations withing the large string, or it may not be in there it all.
I am just trying to test for it's existance(true/false).
Any help would be appreciated.
********************
* $TeVe McLeNiThAn
********************
|
|
|
|
|
See String.IndexOf method in help. This returns the integer index of the first character of a substring in another string, -1 if not foune, 0 if the substring requested is an empty string.
Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
|
|
|
|
|
Hmmm the documentation for String isn't that difficult to follow!
Try String.IndexOf(String)
|
|
|
|
|
How can export specific record(s) in MS Access mdb file to text comma seperated file?
Jassim
|
|
|
|
|
I would look at pulling the stuff into a DataSet and then exporting it as XML instead of csv files. Why do you need it as a text file?
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
ok but can you tell me about the following :
1. can I have a sample code please?
2. Can I protect the XML file with password so that no body will be able to view the contents?
Many Thanks,
|
|
|
|