|
Do you mean you want to check to see if a column, table, view, etc. exists in your database? If so, you can do this easily in SQL Server / MSDE (which is a hell of a lot better than MS Access, and MSDE is free (it is SQL Server without some of the advanced features and limited connections)) using the SCHEMA_INFORMATION tables.
For MS Access, it doesn't provide such meta-data that I'm aware of (I did a lot of programming with access many years ago, but haven't in the last couple years...thank God!). You can use a Module and use the object model to see if objects exists, but I'm not sure how you could execute such a function without using an interop assembly for MS Acccess.
You really should take a look at MSDE, though. It's a royalty-free, relatively small installation (you can even have up to 16 instances of MSDE/SQL Server running on a single machine) with REAL security (both SQL and Windows authentication modes) and is a true RDBMs.
Sorry I couldn't answer your question the way you wanted, but 1) I don't think it's possible (from what I remember, and from what the MS Access documentation says - or rather doesn't say), and 2) MS Access sucks for any serious programs. You can also take advantage of the System.Data.SqlClient namespace elements with MSDE, too - which gives you much better support that generic OLE DB (which is an abstract data access mechanism, after all).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for reply but I don't want to look about a column. I kmow those things about SCHEMA_INFORMATION and other things you say,I want to chheck existence of a record in table. I have two column:First Name and LastName. I want to check if First Name+LastName is unique. I do it in the way that I mentioned in first message but I want to know if there is better way or not.
Mazy
No sig. available now.
|
|
|
|
|
Sorry, your question didn't quite make sense. "Record" instead of "item" would've been the optimal word. I didn't quite follow what you meant.
The way you're doing it (or using the COUNT aggregate and checking for a result value of 1) is fine, but you can create a multi-field index that is unique, thus making a UNIQUE index as you could in MSDE/SQL Server. I know you said you didn't want to do this, but I don't know if you were aware that multi-field indexes are possible.
Just open the Indexes Window for your table. On a new line, type an index name (like "Name"), and select the first field you want. Below that, select the second field you want but do not type an index name. You can do this for up to 10 rows. Finally, go back to the first row and set Unique to Yes. This is documented in the MS Access help. This should also cause an OleDbException to be thrown, which you can catch in a try-catch block and handle gracefully. We do this with SQL Server on our web site quite a bit and just show friendly errors when they occur while logging more information to the trace log (or other event target).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
I don't know if you were aware that multi-field indexes are possible.
I didn't aware of that. I do it in this way now
Well thank you. I learn something useful from you man.
Mazy
No sig. available now.
|
|
|
|
|
Hi!
How do you create an xml file using a C# windows forms?
And also, please tell me to how to read and write on it. Thanks a lot!
ps
Is it possible to query an xml file using C# code? if yes, can you tell me how?
"To teach is to learn twice"
|
|
|
|
|
|
Daljv,
Here is an article I wrote which does all of the things you want to do programatically in C# in a windows application.
http://codeproject.com/csharp/CSPersonalOrganizer1.asp
Good Luck 
|
|
|
|
|
I could not find any function in C# that allows to call exe files. I need some function that does the equal of Visual C 6's WinExec (strCommand, nCmdShow).
e.g. WinExec ("calc.exe", 0);
opens the windows calculator and
WinExec ("notepad.exe", 0); opens the notepad.
Some same stuff in C# ????
|
|
|
|
|
|
I found it in MSDN and ExecCommand (strCommand, strArgs);
but I do not know in which namespace they exists. The msdn page that show the description of this method does not tell the namespace requirements. If you know please do let me know.
|
|
|
|
|
Exec is an internal method within the visual studio ide.
For generic tasks, you should try the 'Process' object.
You can find it in the 'System.Diagnostics' namespace.
ex :
Process.Start("IExplore.exe", "www.northwindtraders.com");
|
|
|
|
|
Thanks alot.
it solved my problem
|
|
|
|
|
hi there,
is there any way to gain the expand collapse feature using c#.I mean something similar to the one we are seeing here.the thread expand/collapse feature..looking forward for the replies and thx in advance.
|
|
|
|
|
You should try searching the forums using "Search Comments" above (search this, the lounge, and anything else that seems relevent). There is code out there and this has been answered before. Google will also reveal some results.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi
I have a code which prints to the printer using the PrintDocument & PrintPreviewDialog classes.
I need to specify at run time which paper size I want to use: A4, Letter, A3 etc. These are not custome sizes but rather standard sizes, listed in the PaperKind enum.
How can I force a certain paper size at run time? The PaperSize.Kind property is read only.
thanks
|
|
|
|
|
In your Print_Page event of PrintDocument:
e.PageSettings.PaperSize
Mazy
No sig. available now.
|
|
|
|
|
To Mazdak!!
Damn man don't you have anything else to do. Go study your exams !!!
|
|
|
|
|
Thanks, but i still have the same problem.
I am trying to:
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
e.PageSettings.PaperSize.Kind = PaperKind.A3;
}
but i does not compile because PaperSize.Kind is read-only.
|
|
|
|
|
You have to construct a new PaperSize like so:
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
e.PageSettings.PaperSize =
new PaperSize("Custom", 11.69 * 100, 16.54 * 100);
} You should also take a look at the PrinterSetttings.PaperSizes documentation. This is a collection that contains each PaperSize that the printer supports. You can enumerate and determine if the printer supports A3 and then get that PaperSize :
foreach (PaperSize size in PrinterSettings.PaperSizes)
if (size.Kind == PaperKind)
return size;
return null;
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I tried this ans it doesnt work, The paper size is still 8.5 x 11. Do I Have to do something else.
Thanks.
Carlos Eduardo Hernandez P.
|
|
|
|
|
See Mazdak's answer that he(/she?) copied from MSDN. I was just answering why you couldn't change the paper size with the code you were using. I thought it seemed weird that the original reply was doing this in PrintDocument.PrintPage .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I try that as well and it didnt work. Am i doing somehting wrong?
thanks.
Carlos Eduardo Hernandez P.
|
|
|
|
|
Are you sure the printer supports that size of paper? Use the other technique I mentioned where you get the sizes that it supports and see if that paper size is in the collection.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I try using the enumeration of papersize and it didnt work. But I really need to define a custom size, not one defined on the printer. Before using .Net, I was using VB6, and in Windows 98, Windows 95, it was very easy to print in any paper size in the printer. But after windows NT, or windows 2000, my vb6 applications could not print on any sizes on those windows. I found out that after windows nt, it has to be creted a form and then attach it to the printer and print. Could it be that I have to do the same thing.
Thanks.
Carlos Eduardo Hernandez P.
|
|
|
|
|
Why didn't enumerating work? That's supported by the Framework plus some Windows function that are P/Invoked and has more to do with the print server and the printer driver than the printer itself.
As far as forms, A3 is already supported so long as you use the dimensions that I gave in a previous example - no rounding! You could try it, though. After all, all the print classes and methods in the Framework are just wrappers for all the functionality in Windows anyway.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|