|
I have been working on a project and have gotten it to a beta point. At this time, I wish to be able to give this application to other people to be able to test out the functionality. To do this, I have been working with creating a setup project. The problem that I run into is that the access database is not in the same location on the new machine as it is on my development platform. As a result, anytime a database call is made an exception is raised.
I have looked for information on how to work with this (books, internet, friends), and have not been able to find any information. The only thing that I did find is that I cannot use xcopy to deploy the application. Does anyone know of an article on this site, or other reference that discusses how to create a setup project that will allow me to set the path for the db on the fly?
Thank you in advance for all of the help,
Eric VanWieren
It is the nature of man to rise to greatness if greatness is expected of him.
- John Steinbeck
|
|
|
|
|
Like you, I've written a couple programs that access a database. In order to do this with ADO.NET(which is what I use), you must set up a connection string inside your OleDBConnection object. The connection string gives(among other things) a path to your database file.
When you add a OleDBDataAdapter object to your form, a wizard pops up to help you set up your connection. For example, when I set up a data adapter to my Access database, the designer adds this line of code to my program:
this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Password="""";User ID=Admin;Data Source= Path to your file here ;Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
I know that looks like a bunch of jibberish, but what you can do is before you open a connection to your database, modify your connection string to reflect where your database is.
Because you don't know where the user will choose to install your program, you can use the System.Environment.CurrentDirectory property to locate where your application is running from and (assuming your database's location is based on the location of the app) append your database's path and name.
My code to do this looks like this:
string CurrentDir = System.Environment.CurrentDirectory;<br />
CurrentDir += "\\DB\\database.mdb";
this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Password="""";User ID=Admin;Data Source=";<br />
this.oleDbConnection1.ConnectionString += CurrentDir;<br />
this.oleDbConnection1.ConnectionString += @";Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
I hope that helps.
Daniel E. Blanchard
|
|
|
|
|
I am an HCI student desperately trying to persuade my supervisor that Web services and smart client apps would provide a good bases for an honours project.
i) Has anyone ever come over any good articles on the issues or any project implementations? I’m currently searching for any written relevant documentation.
MS's Task vision was the kinda’ thing I was, considering until they published it, but a little more single user orientated.
ii) Has anyone ever come across sideshow (sshh!), is it web service consuming or not that smart yet?
Tia
gadget
|
|
|
|
|
Hi there
I am relative new in C# and I would like to save
the content of the TreeView control in my Program.
In other languages there I found something like
treeView->SaveToFile .... or something like that.
I tried already a little bit with Serialize and
BinaryFormatter but it doesn't work at all.
Could someone please help me ?
|
|
|
|
|
when you are saving the nodes on your treeview does it matter how they are saved? as in does order matter? or anything like that ?
if none of that is of concern...(just guessing here) you could use a foreach statement to parse through each node, and then just save the text of the node.
exsample :
<br />
<br />
foreach(TreeNode treenode in treeView.Nodes){
}<br />
Good Luck
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
Hi Jesse.
Yes the order and the Tag-Value of each node is needed --
I am able to save it like you say but I would have to store the Tag separately.
I thought there must be a more elegant way to save the TreeView.
Thatswhy I tried serialization .. but my knowledge of that is no that deep.
.. Thanks for your help !!
|
|
|
|
|
Rather than re-inventing the wheel, have a look at leppie's DUMmeter project here on CP - his code to persist the property grid settings using reflection could be adapted to persist any object, serializable or not.
|
|
|
|
|
Thanks Furty ..
I downloaded that project and it looks good.
I'll try it ...
PS: Your FolderTreeView Project is excellent work I think !
|
|
|
|
|
Hi..All
I am trying to place a IMage on Listview controls' column header. can any one help me to solve that.
Thanks in advance
Cheers!!!
Neo
|
|
|
|
|
The only way to do this would be by hooking into the Windows API - have a look at the ListView control here on CP by Carlos H Perez for inspiration, or simply use his control library.
|
|
|
|
|
Hi!
i made my first control, but in toolbox it has the ugly standard icon. how can i set my own icon?
thanks
|
|
|
|
|
ToolboxBitmapAttribute
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
where is it? i can't find it.
the base class of the control is TreeView
thanks
|
|
|
|
|
OK, this example assumes the control class name is MyTreeView - change it as required:
1) Create a 16x16 bitmap for your control, and place it in the same folder as your control's code file. Set the bitmap name to MyTreeView.bmp, and set the build Action for the bitmap to Embedded Resource.
2) Add the follwing line above your class declaration:
[ToolboxBitmap(typeof(MyTreeView))]<br />
public class MyTreeView : System.Windows.Forms.TreeView<br />
{<br />
}
|
|
|
|
|
I would like to use a UserControl TreeView which is Owner-Draw.
I tried to do it with WndProc(ref message m). I can catch WM_PAINT Function but doesn't help me because I need the ItemRectangle, ItemText and Focused or Selected Properties as well. How can I get these Infos? How can I make the TreeView Owner-Draw.
Is there a message like ITEMDRAW?
Thanks
Stefan
|
|
|
|
|
override OnPaint()
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
That's not enough. I had to this:
this.SetStyle(ControlStyles.AllPaintingInWmPaint|ControlStyles.DoubleBuffer|ControlStyles.UserPaint,true);
So it goes through OnPaint. But now I have a tricky bug perhaps you can help me: I put into the treeview one root node and a child node; painted is only the root-item (altough ExpandAll()). But when I hover over the invisible ChildItem the ChildItem is painted. Strange.
Can you help me?
|
|
|
|
|
I'm looking for a C# class/function/whatever to parse Internet dates (as used in SMTP, NNTP, ...) to System.DateTime. Someone must have already done this, but I can't find anything (found lots of Internet dating services though )
Anyone know any good pointers?
|
|
|
|
|
Bjornar Henden wrote:
Anyone know any good pointers?
Pointers are entirely unsafe and never good.
On a more serious note, have you tried the static
DateTime.Parse()[^] method?
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
I've tried, but haven't had any luck so far. Maybe I haven't tried hard enough, but to me it seems DateTime.Parse parses date strings from a given culture.
|
|
|
|
|
Try DateTime.ParseExact
<br />
String date = "Sun, 06 Nov 1994 08:49:37 GMT";<br />
DateTimeFormatInfo di = DateTimeFormatInfo.InvariantInfo;<br />
DateTime dt = DateTime.ParseExact(date, di.RFC1123Pattern, di);<br />
Console.WriteLine(dt.ToString());<br />
|
|
|
|
|
Thanks for the tip. Exactly what I was looking for. Unfortunately it doesn't seem to handle numeric timezones ("Sat, 01 Mar 2003 15:20:29 +0100"), which I need.
|
|
|
|
|
|
Does anyone know how to make the windows combobox flat like you can with buttons, edits etc.
If it is not posible to make it flat does anyone know of a flat combobox component that i could use?
Thanx
Tim
|
|
|
|
|
Tim, look at the C# Controls > Combo and ListBoxes section here on CP.
|
|
|
|