|
Store the full path to the MDB file in the Web.config using either the AppSettings section or a custom section. This makes it easy to change.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath, thanks for the reply. I haven't much experience with asp.net just trying to make a webpage for the first time using c#. In any event, you mentioned the web.config file. I understand what this file is however I don't really understand what the actually tag if you will is to be in the AppSettings to run the mdb. Could you please post an example for say a database a.mdb that is in the database directory?
Thanks for the help
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
If you don't know what something is, please read the documentation. It will tell you a lot of information.
The <appSettings> section of a .config file stores key/value pairs. Simply use some name you can easily refer to and include the full path to the database (I strongly recommend you keep it OUT of the publicly-accessible web directories):
<configuration>
<appSettings>
<add key="DBPath" value="C:\SomeDir\File.mdb"/>
</appSettings>
</configuration> When you need the path, use something like:
string dbPath = ConfigurationSettings.AppSettings["DBPath"]; Don't forget to check for null returns.
This allows you to change the path in your .config file at any time. For Windows applications, you need to restart the application. For ASP.NET, changes to the Web.config file restart the ASP.NET web application automatically, which reads-in the new values when necessary.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Also, if you want to keep the MDB file in the virtual directories for your web app (not a good idea, unless you properly protected it from being downloaded!), then you must use Server.MapPath or Page.MapPath (whichever is easier in your context) to get the full physical path to the file - referring to it by a virtual file reference will not work - only your web server knows about that, not some OLE DB driver).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I set the back color of my panel to transparent.
Is there any way to prevent the background from moving when I scroll the panel control?
Right now the background scrolls with the scrollbar movement and what I want is for the panel background to not move and remain transparent.
To do this with my tab control I just draw the correct area of the form's background on the tabpage to give the illusion of transparency. However, when the user scrolls the tabpage, the constant redrawing of the image that I have to do slows down the scrolling a bit and is visible (even when I use double buffering).
Does anyone have any suggestions on keeping the panel's background from moving when the user scrolls? (Or how I can keep a tabpage looking transparent without having to redraw an image every time it gets a scroll message)?
Thanx for the help,
-Flack
|
|
|
|
|
You can't keep the background from moving. But what you can probably try is keeping the background of the panel transparent and then put an image under the panel. This will keep the image steady and the panel moving, but you might have redraw performance issues...
RageInTheMachine9532
|
|
|
|
|
if i want to add a new user to microsoft exchange mail server not through the active directory manually but through asp.net so the user can add it from the interface?/
how i heard about the ldap
emy
|
|
|
|
|
Umm... Active Directory i think IS Microsoft's LDAP implementation.
|
|
|
|
|
Hi Everybody,
I wrote a class like this
public class Node
{
private int data;
private string key;
#region Constructors
public Node(string key, int data)
{
this.key = key;
this.data = data;
}
#endregion
#region Public Properties
public int Value
{
get
{
return data;
}
set
{
data = value;
}
}
public string Key
{
get
{
return key;
}
set
{
key = value;
}
}
#endregion
}
public class test
{
public static void Main()
{
ArrayList a = new ArrayList();
Node n = new Node("ab", 1);
a.Add(n);
PrintValues(a);
}
public static void PrintValues( IEnumerable myList )
{
System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.Write( "\t{0}", myEnumerator.Current.ToString());
Console.WriteLine();
}
}
My problem is How do I get and set values for each node in this Array List and How do I print out to the screen.
Thanks for your help and time.
Raj
|
|
|
|
|
You have to cast the elements of your ArrayList.
<br />
public static void PrintValues( IEnumerable myList ) <br />
{<br />
System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();<br />
while ( myEnumerator.MoveNext() )<br />
{<br />
Console.Write( "\t{0}", ((Node) myEnumerator.Current).Key.ToString());<br />
Console.WriteLine();<br />
}<br />
}
|
|
|
|
|
Please take a good look at this and give me some clues!!!
I need to list every table in the Access database.
This code (which is from the .NET Framework Class Library DataTableCollection Class page on MSDN) appears to get the info that is needed, but what does the dataset coding look like for this to work?
private void GetTables(DataSet ds) <br />
{ <br />
foreach (DataTable t in ds.Tables) <br />
foreach (DataRow r in t.Rows) <br />
foreach (DataColumn c in t.Columns) <br />
if (r[c] != null) <br />
Console.WriteLine(r[c]); <br />
}
Regards,
Bill Antonacchio
|
|
|
|
|
Hi Bill. You're going to want to use the GetOleDbSchemaTable method of the OleDbConnection object to get your list of tables. This Microsoft KB document should help.
http://support.microsoft.com/?id=309488[^]
|
|
|
|
|
|
Thanks Mike I will give that a try.
Regards,
Bill Antonacchio
|
|
|
|
|
Yes, I know about the registry, but I need to read an ini file.
Could you point me towards the C# counter part of
GetPrivateProfileString.
thanks
|
|
|
|
|
http://www.codeproject.com/csharp/ReadWriteXmlIni.asp
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
There's already a class in the Files And directories category, and I have published another today, so if it does't get available, send me an email!
kratchkov@inbox.lv
|
|
|
|
|
|
I want to create a toolbar that is very narrow and vertical. In the design mode this is very easy. BorderStyle=None. Dock = DockStyle.Left.
That said, the dialog box expands 3 fold in runtime mode.
Any suggestions on how to create a very narrow / verticle toolbar?
thanks
|
|
|
|
|
Try setting the maximum, and minimum sizes of the application to the same size to restrict it from changing.
this.MinimumSize = new Size(40, 400);
this.MaximumSize = new Size(40, 400)
It shouldn't be expanding on its own like that, unless there is something that is causing it to do so. By setting the min/max sizes, it will remain the same size no matter.
|
|
|
|
|
Does someone know how to eject and/or close cdrom trays in C#?
|
|
|
|
|
Download this nice application http://www.brightweb.co.uk/CDROMManager.zip
|
|
|
|
|
Try this:
using System.Runtime.InteropServices;
[DllImport("winmm.dll", EntryPoint="mciSendString")]
public static extern int mciSendStringA(string lpstrCommand, string lpstrReturnString, long uReturnLength, long hwndCallback);
mciSendStringA("Set CDAudio Door Open Wait", null, 0, 0);
to close it I believe its "Set CDAudio Door Close Wait", null, 0, 0);
I can't test it on my system because mine doesn't have autoclose i have to manually close it.
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
hai there,
i have a query to ask you(related remoting concept). See i have a class in my server machine and this class is reused by the client machine. After accessing the facilities of server class my client machine will release the server object.
My question is how can i keep track of total how many times my server class is used by other clients.
how can i impliment this counter concept.
Note : concept is same as no of times a perticular webpage is visited.
but here my application is windows application.
hai, feel free to contact
Sreejith SS Nair
|
|
|
|
|
In your class define a static field (static int instanceCount = 0), and then in the constructor increment this with instanceCount++
And decrement in the destructor.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|