|
Because it's not using the Outlook object model.
There is also a library ($$$) that solves the problem, but it is not free.
|
|
|
|
|
hello,everyone:
i'm a beginner of C#,i use crystal report do report.
Now,in my project,i use Dategridview to show datebase,the serach Condition is two
DataTimerPicker.now,i just want the dates which is searched to report,but everytime when i do the report,it'll report all the dates in my datebase,but i just want report some of them,no all!i know Crystal Report can do this job very good,but i do not know how to make my code,so please everyone show me some method or give some others to teach me!Very appriate!
Student miss YY
modified on Wednesday, January 6, 2010 9:51 PM
|
|
|
|
|
hi,
you can try the following links,
http://www.codeproject.com/KB/cs/CreatingCrystalReports.aspx
http://csharp.net-informations.com/c...stepbystep.htm
There are examples of a step by step help for crystal reports in C#,
it may help you.
modified 27-May-14 5:04am.
|
|
|
|
|
thanks very much!
i can't login "
|
|
|
|
|
If I want to know what kind of encoding a certain file is already saved as, which method do I use?
I can't use following because by creating streamwriter constructor, it will save the file as UTF-8 encoding:
StreamWriter sw = new StreamWriter(@filepath);
so by providing a path to a file, not sure how I can detect which encoding the file has..
can anyone please help me?
|
|
|
|
|
Hi,
you could open the file for reading and get the first few bytes of the existing file; then check those for the special codes that are present in UTFx encoded files, something along these lines:
if (len>=3 && buffer[0]==0xEF && buffer[1]==0xBB && buffer[2]==0xBF) {
encoding=65001;
} else if (len>=2 && buffer[0]==0xFF && buffer[1]==0xFE) {
encoding=1200;
} else if (len>=2 && buffer[0]==0xFE && buffer[1]==0xFF) {
encoding=1201;
} else {
encoding=1252;
}
later on, you can create a StreamWriter that takes the encoding into account, by using one of the constructor overloads and an Encoding instance.
|
|
|
|
|
hi, the following code may help you.
System.Text.Encoding enc = null;
using (System.IO.FileStream file = new System.IO.FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
if (file.CanSeek) { byte[] bom = new byte[4]; // Get the byte-order mark, if there is one
file.Read(bom, 0, 4);
if(bom[0] == 0xef && bom[1] == 0xbb && bom[2] == 0xbf)
{
enc = System.Text.Encoding.UTF8;
}
else if (bom[0] == 0xff && bom[1] == 0xfe)
{
// ucs-2le, ucs-4le, and ucs-16le
enc=System.Text.Encoding.Unicode;
}
else if(bom[0] == 0xfe && bom[1] == 0xff)
{
// utf-16 and ucs-2
enc=System.Text.Encoding.BigEndianUnicode;
}
else if(bom[0] == 0 && bom[1] == 0 && bom[2] == 0xfe && bom[3] == 0xff)
{
// ucs-4
enc = System.Text.Encoding.UTF32;
}
else
{
enc = System.Text.Encoding.ASCII;
}
}
else
{
// The file cannot be randomly accessed, so you need to decide what to set the default to
// based on the data provided. If you're expecting data from a lot of older applications,
// default your encoding to Encoding.ASCII. If you're expecting data from a lot of newer
// applications, default your encoding to Encoding.Unicode. Also, since binary files are
// single byte-based, so you will want to use Encoding.ASCII, even though you'll probably
// never need to use the encoding then since the Encoding classes are really meant to get
// strings from the byte array that is the file.
enc = System.Text.Encoding.ASCII;
}
return enc;
}
best wishes.
modified 27-May-14 4:59am.
|
|
|
|
|
Thank you so much, Carle!
but there are so many other encodings such as GB18030-codepage 54936,, etc. if you look under 'Advanced Save options' in Visual Studio, you will see a bunch of different encodings.
with your case, it seems like that if the encoding doesn't fall under any of the UTF-x, you set the encoding as ASCII. but what if the encoding of the file is some other encoding?
Thanks!
|
|
|
|
|
Hello
I´m using an excellent tutorial:
http://www.codeproject.com/KB/grid/usingdatagrid.aspx
I'm not using MS Access, what is recommended in the tutorial, but MS SQL Comapact Edition as Data Provider. This shoult doesn't make a different.
But every time I try to execute the following code, an error message appear.
And the dataGrid is not displayed on the form.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
namespace DataGridViewTest
{
public partial class Form1 : Form
{
private System.Windows.Forms.DataGrid dataGrid1;
public Form1()
{
InitializeComponent();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGrid1.Location = new System.Drawing.Point(20, 20);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(200, 100);
}
private void fnDisplayDataInDataGrid()
{
string conStr = "Data Source=C:\\CSharp\\DataGridViewTest\\DB_Personen.sdf";
SqlCeConnection conn = new SqlCeConnection(conStr);
conn.Open();
SqlCeDataAdapter adapter = new SqlCeDataAdapter("SELECT * FROM Adressen", conn);
DataSet ds = new DataSet();
adapter.Fill(ds, "Adresse");
this.dataGrid1.DataSource = ds.DefaultViewManager;
}
private void Form1_Load(object sender, EventArgs e)
{
fnDisplayDataInDataGrid();
}
}
}
The error message predicate I need a DLL. But wich DLL and where can I get it ?
A first chance exception of type 'System.DllNotFoundException' occurred in System.Data.SqlServerCe.dll
Can someone help me, please ?
Sincere regards
Samuel
|
|
|
|
|
There are a few things. Please edit uand use <pre></pre> tags around your code. I usaly don't bother reading unformated code
Doltsche wrote: A first chance exception of type 'System.DllNotFoundException' occurred in System.Data.SqlServerCe.dll
Witch dll? if you tried running without debug, windows usaly shows witch dll are missing. This is not problem with a code, better reinstal your database.
Or it coud be that you are refencingn to incorect dll. Try remove from reference and add again
|
|
|
|
|
Hello
Thanks for the answer.
Sorry for my english, I can only a little bit.
I have the Code now written in VS 2010 and added the same Datasource.
However, the previous error message doesn't appear anymore but a other message appear:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll
Although, the Application run. But the DataGrid is still not shown.
I haven't any idea how I can solve this problem. Please help me. Thanks
regards
Samuel
|
|
|
|
|
I do not know whay this problems occour.
Doltsche wrote: But the DataGrid is still not shown
You mean data in DataGrid is not shown or DataGrid itself doesn't show?
In your code you forgot to use DataMember beside DataSource. Here is mine example and it worked. I didn't use MS Sql as i do not have installed. I usaly use MySQL.
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.TableName = "Boo";
dt.Columns.Add("Test");
dt.Columns.Add("Failed");
dt.Rows.Add(new Object[]{"Wil it work?","Hahaha, I lost my Mind"});
ds.Tables.Add(dt);
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "Boo";
Look at the last line. That line is missing from your code. Have you tried using another test project using designer and auto generated code? I do not know witch tutorial recomend MS accsess as database, but that is the last thing on the list that I would reccomend. MS accsess is great for a Local database as long there is only one connection to it.
|
|
|
|
|
Hi all,
Im trying to write some data to a excel file. the problem is that if the file is open, then im getting a exception.
How can i catch/fix this ?
Thanks
|
|
|
|
|
Close it?
Or use liquid nitrogen.
|
|
|
|
|
With your question and info you provided there is a slim chance to anybody know what your problem is.
Witch Exception is thrown?
Priya Prk wrote: the problem is that if the file is open, then im getting a exception.
Please elaborate. As long your app has open you should be able to write. The impression I get from this part is: How do I open a Excel file while it was Exclusive opened by another application. (Exclusive opened means that file opened by one app cannot be accsessed by another App)
|
|
|
|
|
If the file is already opened (by Excel or any other app), then you have no choice but to wait until whichever process has the file open gets around to closing it. Then you can open the file in your app.
|
|
|
|
|
what's connection string for sdf file ?
|
|
|
|
|
|
I used this connectionString
"Data Source=|DataDirectory|TMCDataBase.sdf;Persist Security Info=False"
Error : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
|
|
|
|
|
How did you initialize the connection?
I think you have used this:
conn = new SqlConnection("Data Source=|DataDirectory|TMCDataBase.sd;Persist Security Info=False");
But the correct way is:
conn = new SqlCeConnection("Data Source=|DataDirectory|TMCDataBase.sd;Persist Security Info=False");
In order to use SqlCeConnection class, you should reference System.Data.SqlCe.dll.
|
|
|
|
|
I am looking for a way to subscribe to system events so when a new system event is added to the system event log, I can be notified and grab information about the event. So far I have found a way to grab system events, however I do not know how to use this to be notified when a new event has been logged. I also found a way to listen for system events, but this
way is limited to certain events and does not provide the information on the event that I need. Any suggestions on either a new way to get what I need or how to use what I already found? Thanks.
|
|
|
|
|
Solved, used EntryWrittenEventHandler in System.Diagnostics.EventLog
|
|
|
|
|
I need datagridview component that I can show picture and
Information of peopel in it (Like XamDataGrid)
please help me
|
|
|
|
|
How about DataGridViewImageColumn? Are you looking for something more than that?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
datagrid like XamDataGrid but XamDataGrid is wpf I need component for win application
|
|
|
|