|
Please give it some thought about forcing a clients machine to reboot. Just think how irritating it is when an application reboots your machine. Personaly believe the best option is to place messages in the installer to say a reboot is necessary, and leave it up to the end-user.
My one cent.
|
|
|
|
|
Has anyone used C# to do a mailmerge for word 2002?
I have a CSV file that is coma delimited that is created by a web page. Need to take that CSV file and have it do a mailmerge to a Word doc.
|
|
|
|
|
Anonymous wrote:
Has anyone used C# to do a mailmerge for word 2002?
Google is your friend. Go to Google and do a search on the keywords in your question (hint)[^].
Roger Stewart
"That is disgusting... Yet oddly fascinating!"
|
|
|
|
|
Any know what I'm doing wrong? I have this mailmerge and it does not seem to Close WINWORD.EXE.
I also tried using oWordDoc.Close(ref oFalse, ref missing, ref missing); line in the code and it will not close it either. Tried using both oWordApp.Application.Quit(ref oFalse, ref missing, ref missing); and oWordDoc.Close(ref oFalse, ref missing, ref missing); Then it seems to hang the web page. Any help would be nice.
object fileName = "c:\\temp\\letter.doc";
string SourceFile = "c:\\temp\\Names.csv";
object SourceFormat = Word.WdOpenFormat.wdOpenFormatText;
object oFalse = false;
object oTrue = true;
object missing = System.Reflection.Missing.Value;
object query = "SELECT * FROM `DirectMailList123200311834$`";
object SaveAsFileName = "c:\\temp\\MergedLetter.doc";
Word.Application oWordApp = new Word.Application();
Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing, ref oTrue, ref missing,ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
oWordDoc.MailMerge.OpenDataSource(SourceFile, ref SourceFormat, ref missing, ref missing, ref oTrue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,ref query,ref missing,ref missing, ref missing);
oWordDoc.MailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
oWordDoc.MailMerge.Execute(ref oFalse);
oWordApp.ActiveDocument.SaveAs(ref SaveAsFileName, ref missing, ref missing, ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing);
oWordApp.Application.Quit(ref oFalse, ref missing, ref missing);
|
|
|
|
|
Hi everybody
Does anyone know if there is a way to implement named pipes using C#?
Thank you very much!!
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
First, let me just say that .NET Remoting is the recommended way for inter-process communication - even over disparate networks like the Internet. See the System.Runtime.Remoting namespace for more information, or read the MS Press book, ".NET Remoting" (it's pretty good for both beginners and advanced developers alike).
Having said that, you have to P/Invoke the CreateNamedPipe function and create a SECURITY_ATTRIBUTES structure like so:
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr CreateNamedPipe(string name, int openMode, int pipeMode,
int maxInstances, int outBufferSize, int inBufferSize,
int defaultTimeout, ref SECURITY_ATTRIBUTES);
[StructLayout(LayoutLind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
public int length;
public IntPtr securityDescriptor;
public bool inheritHandle;
} If you don't want to worry about the SECURITY_ATTRIBUTES struct in the CreateNamedPipe method, you could probably change the param to a generic object and pass null when calling the method. See the SDK documentation for CreateNamedPipe for details about what else to pass.
Now, that returns you a handle (IntPtr in .NET). You can use that in a call to the constructor for FileStream :
IntPtr handle = CreateNamedPipe(@"\\.\pipe\Name123", ...);
Stream s = new FileStream(handle, FileAccess.ReadWrite); Now you've got a Stream to work with using managed code.
-----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'm trying to play a variety of sounds ( .wav files ) in a C# program and am having problems doing so. First off, I couldn't find any .NET native way to do so. Then I wanted to use the Win32 API call PlaySound, but since it's a lib and not a dll I can't do that. Finally, I wanted to use DirectX9, but after installing the SDK, if I put "using Microsoft.DirectX;" on the top of my form it says it doesn't exist.
Any clues?
Thanks,
|
|
|
|
|
DirectX is the way to go, but putting using Microsoft.DirectX isn't enough (and you'll want to use the Microsoft.DirectX.DirectSound namespace anyway). You actually have to add the appropriate assemblies to your project references. Right-click on your project and click "Add Reference". Find the appropriate assemblies (Microsoft.DirectX and Microsoft.DirectX.DirectSound) and add them to your project. For any classes you use, you must include the assembly that contains that class in your project references (except for classes in mscorlib.dll, which is automatically referenced unless the compiler is told otherwise - which you can't do from VS.NET).
-----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-----
|
|
|
|
|
Ok, I wanted to do that, but they don't appear. I can't add them under the ".Net" tab.
|
|
|
|
|
Do the same thing and click the "Browse" button. Browse to those assemblies and double-click to add them.
-----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-----
|
|
|
|
|
Could you please be more specific? What file exactly do I have to browse to, and where would it be located. I searched my harddrive for Microsoft.DirectX and nothing was found. I have some XML files with the appropriate names, but that's it.
|
|
|
|
|
shizam wrote:
Could you please be more specific?
Could you be more explorative? I mean, it's not that hard. If you have installed the DirectX SDK (with the managed assemblies - yes, you actually have to go to msdn.microsoft.com/directx and download it), they would show up in a search. If you still can't find them, they're installed into %WINDIR%\Microsoft.NET\Managed DirectX\vVERSION. Select the appropriate assemblies which - agian - I did give you the names of in the first place. If you don't see them, then go to a folder's Tools->Folder Options, then click the View tab and show hidden files. Any good developer should've already enabled this option since working with DLLs and other normally hidden files is necessary.
Figuring out things for yourself will teach a lot more than having people do them for you.
-----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-----
|
|
|
|
|
Well Heath, maybe you shouldn't be answering questions if you're going to be mean about it.
1) I've been trying to solve this problem over 2-3 days, so I did not immediately jump and ask for help the first time I had a problem
2) I do have "show hidden files" enabled because I've experienced those types of problems before. Your comment that "Any good developer should've already enabled.." this options is ridiculous. People make mistakes, even good developers.
3) Yes I've installed the DirectX SDK, it's a 227 MB self extracting exe that was downloaded from Microsoft's web site.
4) In the directory you specify, I only have .XML files, and no DLL files.
So please don't respond anymore unless you're going to provide answers or suggestions. If you want to ridicule people, log on to chat.yahoo.com
|
|
|
|
|
These forums are for developers, not for people looking to others to do their work for them. Check practically any replies from the regulars and you'll see it isn't just me.
Even if you've installed the DirectX SDK, there is a separate install for the managed runtime. If you took the default path for the SDK installation, the install would be in C:\DX90SDK\Developer Runtime\Managed DirectX\Retail for the release builds, or replace Retail above with Debug for the debug build.
One more thing - all this was discussed on the URL I previously gave you for the DirectX SDK download site and for other information - including samples - about DirectX 9. Reading documentation is essential, SDK documentation and installation guides.
-----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-----
|
|
|
|
|
Well I am a "professional developer", have been once since leaving college with my piece of paper.
I'm trying to set up .NET and DirectX and not having much luck here.
The directory mine was installed to was "C:\DXSDK", and that was the default.
I do NOT have the "Developer Runtime" sub-directory under there.
I'm read the readme's and most of the stuff on that link you were talking about already, no luck.
|
|
|
|
|
Go to http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp[^] and click on the Redist[^] link.
Make sure you download the Summer 2003 updates because many bugs were fixed. This is both a full and upgrade installation so you don't really need to uninstall the previous version.
-----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-----
|
|
|
|
|
|
shizam wrote:
Then I wanted to use the Win32 API call PlaySound, but since it's a lib and not a dll I can't do that.
Umm... it's both. Declare it like this and you should be fine:
[DllImport("winmm")]
public static extern int sndPlaySound(string lpszSoundName, int uFlags);
|
|
|
|
|
...preloading the printPreviewDialog?
I want to disable the messagebox/dialog that shows the number of pages loading before the printPreviewDialog is shown. Is there a way around that by any chance?
Many thanks in advance.
// Loke
|
|
|
|
|
Hi,
I am trying to learn ADO.net using C# and I keep running into problems trying to insert data into my Access Database: data.mdb.
here is my code:
<br />
private string connectionStr = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source=""C:\data.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";<br />
private string selectStr = "Select id, date, day, time, comments, timeout, status, process from data";<br />
<br />
private System.Data.DataSet myDataSet;<br />
private System.Data.OleDb.OleDbConnection myConnection;<br />
private System.Data.OleDb.OleDbDataAdapter myDataAdapter;<br />
private System.Data.OleDb.OleDbCommandBuilder myCmdBuilder;<br />
<br />
private System.Data.OleDb.OleDbCommand mySelectCmd;<br />
<br />
public Schedule()<br />
{ <br />
this.InitilizeDb();<br />
this.PopulateDataSet();<br />
}<br />
<br />
private OleDbConnection ConnectDb()<br />
{<br />
return new OleDbConnection(connectionStr);<br />
}<br />
<br />
public void InitilizeDb()<br />
{<br />
myDataAdapter = new OleDbDataAdapter();<br />
myCmdBuilder = new OleDbCommandBuilder(myDataAdapter);<br />
myDataSet = new DataSet();<br />
}<br />
<br />
private void PopulateDataSet()<br />
{<br />
myConnection = (OleDbConnection) this.ConnectDb();<br />
<br />
mySelectCmd = new OleDbCommand(selectStr, myConnection);<br />
<br />
mySelectCmd.CommandType = CommandType.Text;<br />
<br />
try<br />
{<br />
myConnection.Open();<br />
<br />
myDataAdapter.SelectCommand = mySelectCmd;<br />
<br />
myDataAdapter.Fill(myDataSet,"data");<br />
}<br />
finally<br />
{<br />
myConnection.Close();<br />
}<br />
}<br />
<br />
public string InsertSchedule(string date, string day, string time, string process,<br />
string comments, string timeout, string status)<br />
{<br />
myConnection = (OleDbConnection) this.ConnectDb();<br />
<br />
try<br />
{<br />
myConnection.Open();<br />
<br />
DataRow newRow = myDataSet.Tables["data"].NewRow();<br />
<br />
newRow["id"] = 3;<br />
newRow["date"] = date;<br />
newRow["day"] = day;<br />
newRow["time"] = time;<br />
newRow["process"] = process;<br />
newRow["comments"] = comments;<br />
newRow["timeout"] = timeout;<br />
newRow["status"] = status;<br />
<br />
myDataSet.Tables["data"].Rows.Add(newRow);<br />
<br />
myDataAdapter.Update(myDataSet, "data");<br />
<br />
return "true";<br />
}<br />
catch(Exception e)<br />
{<br />
return e.Message + "\n\n" + e.StackTrace + "\n\n" + e.InnerException;<br />
}<br />
finally<br />
{<br />
myConnection.Close();<br />
}<br />
}<br />
the problem is when I try to insert into the database, I keep getting this Exception:
Syntax error in INSERT INTO statement.<br />
<br />
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)<br />
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)<br />
at ShutdownMgr.Schedule.InsertSchedule(String date, String day, String time, String process, String comments, String timeout, String status) in c:\documents and settings\azel\my documents\visual studio projects\shutdownmgr\schedule.cs:line 99<br />
I have tried different ways but none were successful. Is anyone able to spot where I am going wrong?
thanks.
|
|
|
|
|
Because you haven't specified a INSERT SqlCommand . The SqlDataAdapter isn't magical - you need to provide SELECT, INSERT, UPDATE, and DELETE SqlCommand s for full functionality. Specifying just a SELECT SqlCommand doesn't generate the others. If you're unsure about how to do this, read about the SqlCommand and SqlDataAdapter classes in the SDK documentation, or use drop a SqlDataAdapter onto your form or control in VS.NET and run through the wizard. Be sure to look at what source it generates though to fully understand what is going on.
-----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-----
|
|
|
|
|
Oic,
I thought the commandbuilder class is suppose to auto generate the insert, update and delete commands?
so even if i have set the commandbuilder to my data adapter, I must still initilize my insert, update and delete commands?
I will also take a look at the SDK documentation..
thanks.
|
|
|
|
|
I missed that line, sorry. The SqlCommandBuilder may have trouble with your SELECT statement. Another possibility is with the table mappings of the SqlDataAdapter . You're setting your table name as "data". Does that actually map to the name of the table from which you're selecting records? These should match and you might have to set up a table mapping using the SqlDataAdapter.TableMappings property. This fairly straight-forward.
-----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-----
|
|
|
|
|
the dataset table name is "data" which is the same as the one from the source table name.
i got the idea from MSDN that table mapping is use when your data source and dataset names are different? So if I have used the same name do I still need tablemapping?
thanks
|
|
|
|
|
Yes, unless you use a strongly-typed DataSet . In most cases, the SELECT SqlCommand (with one or multiple result sets) loads tables by default named "Table", "Table1", "Table2", ..., "TableN". Your TableMappings should map these table names to your actual tables in your database.
-----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-----
|
|
|
|
|