|
It is a very generic error message. Not much help can be offered from this. All I can say is that there is some error in the COM component's method you had called.
Take a look at this[^] blog. It might help.
|
|
|
|
|
I was wondering if you can print a report without the report viewer?
Right now, a user can right click the ListView and select View Ticket and it will bring up a Windows Form with a report viewer in it (linkd to TicketView.rdlc) and it will view the printable version of the ticket.
Now on the same context menu I put a Print Ticket button. My intensions was the user can view the ticket in printable format then print it, or the user could just click the Print Ticket button and it would print it exactly like you would view it in the report viewer.
Right now my ViewTicket.cs (Windows Form) has the dataset, binding source, and table adapter. When this form is opened, the ID (SQL) is passed to the windows form. Then we fill the table adapter using the ID. Now my other forms didnt do it this way since they needed more input before viewing the report. It seemed when I tried this with the forms Load event it wouldn't work.
Here is how I passed the parameters during the Loading of the form (this DIDNT work)
ReportParameter[] parm = new ReportParameter[1];
parm[0] = new ReportParameter("ID", ID.ToString());
reportViewer1.LocalReport.SetParameters(parameters);
reportViewer1.RefreshReport();
Now this exact code would work if I put a button on the form and ran this code during the button click event. But its like the report can't refresh because the form is loading maybe? Not sure..
Anyways, so how exactly could I print this report without going to the report viewer? I understand I would need to pass the ID to the report still, but how do I skip the viewing the report with the reportviewer and printing it from there? How can I just go straight to printing the report with one click of a button?
|
|
|
|
|
Hi all,
How to call the anchor? I am using ItextSharp.dll
My textbox is: webpageurl
i want my textpage able to capture this website after i click the button <<OK>>
What can i put for >>
Using._______._____; to call the anchor ?
How to continue from here?
Anchor anchor = new Anchor("website");
anchor.setReference("http://www.lowagie.com/iText/");
anchor.setName("website");
Anchor anchor1 = new Anchor("This is an internal link");
anchor1.setName("link1");
Anchor anchor2 = new Anchor("Go to the internal link");
anchor.setReference("#link1");
ThankYou
|
|
|
|
|
Whatever ITextSharp is, I assume it comes with samples and docs. I also assume that most people here have as little idea about it as I do, as this is not a forum for users of this dll.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
can i give a standed size to all my new appiering MSN boxes???
A S E L A
|
|
|
|
|
No, you have to create your own to specify size.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
how can i maximize my form when i click on maximize button on top right sid conner??? when i click it just maximize my form bu it didn't work for items in the Form i mean like ListView Boxes, text Boxes, etc....how can i do that?
|
|
|
|
|
Anchor or dock them as appropriate.
|
|
|
|
|
ya i got it...thanks a lot....
A S E L A
|
|
|
|
|
|
ya managed to do that....thanks a lot for ur advice....
A S E L A
|
|
|
|
|
i using this codes.....some times i get this error message...any one know why????
"the process cannot access the file because it is being used by another proces"
this is the message but its not using any other process...
here is my code
foreach (ListViewItem item in listView2.SelectedItems)
{
listView2.FocusedItem = istView2.Itemitem.Index]; DSOFile.OleDocumentPropertiesClass file = new DSOFile.OleDocumentPropertiesClass();
file.Open(listView2.FocusedItem.Text, false, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
file.SummaryProperties.Title = tbxTitle.Text; file.SummaryProperties.Subject = tbxSubject.Text; file.SummaryProperties.Keywords = tbxKeywords.Text;
file.SummaryProperties.Author = tbxAuthor.Text; file.SummaryProperties.Comments = tbxComments.Text; file.Close(true);
MessageBox.Show("Changes Added into Selected File"); }
A S E L A
|
|
|
|
|
The file's already open, or in use somewhere. Either by another application, or by yours in unshown code.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
you know it not come out allthe time...its come out only for first picture.
in my applicartion i got two listview boxes. i load images in to one and drag drop few in to other listview box.if i drag only one picture and when i attempt to change & save summary prop i got this msg...if i drag 1 < pictures its not come out......
A S E L A
|
|
|
|
|
... then somwhere in that logic you've still got the file open.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
There are bugs in .NET wrt opening images, your best bet is to open your image, copy it to a new image, and then dispose of the old image, to make sure the file is not locked.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
copy mean temparery copy in to another folder or copy in to application.....if it is to application i don't know how to do that....but if it is to temp folder i can manage to do that....can u please just explane that bit...
thanks a lot....Christian
A S E L A
|
|
|
|
|
Hello,
Can someone suggest how I can improve the code below to use just one kind of SQL connection to read both the Database table column names and the records in the table? I am using OleDb to read the column names from the table, then SqlCommand to read the records, but I would like to use only the one or the other. How can I read the DB records using OleDb please?
Can I use SqlCommand to read the column names from the table schema?
I am using Visual C# 2005 Express.
Thank you for taking the time to read this!
using System;
using System.IO;
using System.Text;
using System.Data;
using System.Collections;
using System.Data.OleDb;
using System.Threading;
using System.Data.SqlClient;
using System.Configuration;
namespace exportToCSVfile
{
public class Program
{
static int Main( string[] args )
{
OleDbConnection connOleDB = new OleDbConnection();
connOleDB.ConnectionString = ( the connection string );
SqlConnection conn = new SqlConnection( another connection string );
DataTable schemaTable;
string strRow;
string fileOut = ConfigurationManager.AppSettings["directoryPathKey"] + ConfigurationManager.AppSettings["fileCSVNameKey"];
string fileLogFullPath = ConfigurationManager.AppSettings["directoryPathKey"] + ConfigurationManager.AppSettings["fileLogNameKey"];
if ( !Directory.Exists( ConfigurationManager.AppSettings["directoryPathKey"] ) )
{
Console.WriteLine (
"Directory \"{0}\" does not exist", ConfigurationManager.AppSettings["directoryPathKey"]);
Console.ReadLine();
return 0;
}
try
{
connOleDB.Open();
schemaTable = connOleDB.GetOleDbSchemaTable( OleDbSchemaGuid.Columns,
new Object[] { null, null, "SomeDatabaseTable", null } );
int theArrayBounds = schemaTable.Rows.Count;
string[] columnNames = new string[theArrayBounds];
for ( int i = 0; i < schemaTable.Rows.Count; i++ )
{
object objColumnNames = ( schemaTable.Rows[i].ItemArray[3].ToString() );
columnNames[i] = objColumnNames.ToString();
}
connOleDB.Close();
string sqlQuery = "SELECT * FROM SomeDatabaseTable";
SqlCommand command = new SqlCommand( sqlQuery, conn );
conn.Open();
SqlDataReader dr = command.ExecuteReader();
DataTable dtSchema = dr.GetSchemaTable();
StreamWriter sw = new StreamWriter( fileOut, false, Encoding.Default );
string columnHeaderString = String.Join( ",", columnNames );
sw.WriteLine( columnHeaderString );
while ( dr.Read() )
{
strRow = "";
for ( int i = 0; i < dr.FieldCount; i++ )
{
strRow += Convert.ToString( dr.GetValue( i ) );
if ( i < dr.FieldCount - 1 )
{
strRow += ",";
}
}
sw.WriteLine( strRow );
}
sw.Close();
conn.Close();
}
catch ( Exception exception )
{
Console.WriteLine( exception );
Thread.Sleep( 3000 );
using ( TextWriter tw = new StreamWriter( fileLogFullPath ) )
{
tw.WriteLine( DateTime.Now + "Error: " + exception.ToString() );
}
connOleDB.Close();
conn.Close();
return 0;
}
finally
{
connOleDB.Close();
conn.Close();
}
return 1;
}
}
}
I have taken help from various sources for the code and I extend my most grateful thanks;
http://www.codeproject.com/KB/database/Cs_CSV_import_export.aspx[^]
I would include other references but I've lost those links during my extensive searching.
modified on Thursday, March 12, 2009 3:49 PM
|
|
|
|
|
I have a little problem I need some help with. IM a novice C# programmer.
Im working on a piece of software that scans a directory for mp3 files loading the filepaths into an array. It then reads some info from the ID3 tags and attempts to write this info to an Access database. All seems to work fine except after about 25 files I get a System.OutOfMemory Exception. Im thinking either the ID3Info objects or the OleDbCommand objects arent disposing correctly so I threw in the System.GC.Collect and it did succeed in getting me farther but Im still getting the error. Anyone see anything Im missing?
int i = 0,duration, year;
string artist, title, album, bandname, genre, path;
string delSql = "DELETE * FROM Library";
musLibConn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GeneSys\Library.mdb";
OleDbCommand deleteLib = new OleDbCommand(delSql, musLibConn);
musLibConn.Open();
if (tbMusPath.Text != "")
{
utility util = new utility();
filepaths = Directory.GetFiles(util.getLibPath(), "*.mp3", SearchOption.AllDirectories);
deleteLib.ExecuteNonQuery();
ID3Info CurrSong;
OleDbCommand insertLib;
pBar.Visible = true;
foreach(string str in filepaths)
{
CurrSong = new ID3Info(filepaths[i], true);
path = filepaths[i].ToString();
artist = CurrSong.ID3v2Info.GetTextFrame("TPE1").ToString();
title = CurrSong.ID3v2Info.GetTextFrame("TIT2").ToString();
album = CurrSong.ID3v2Info.GetTextFrame("TALB").ToString();
lblPath.Text = path;
string insSql = "INSERT INTO Library(Artist,Title,Album,Path)"+
"VALUES('"+artist.Replace("'","''")+"','" + title.Replace("'","''") + "','"+
album.Replace("'","''")+ "','" +path.Replace("'","''") + "')";
insertLib = new OleDbCommand(insSql, musLibConn);
insertLib.ExecuteNonQuery();
i++;
System.GC.Collect();
}
pBar.Visible = false;
lblNum.Text = Convert.ToString(filepaths.Length);
util.setNoFiles(filepaths.Length);
Thanks for the help
Jon
|
|
|
|
|
Hi Jon,
adding some GC.Collect() calls is not the way to fix programming mistakes. What you need to do is call Dispose() on those objects you don't need any longer, provided their class has such a method.
In your case, insertLib = new OleDbCommand(insSql, musLibConn); is the most likely culprit: inside the loop you create OleDbCommand instances, use them, then let them fade into oblivia (by assigning a new OleDbCommand to insertLib, the old one is gone, but still occupies memory.
I suggest you do not declare OleDbCommand insertLib; outside the foreach loop, instead do
foreach (...) {
OleDbCommand insertLib=new OleDbCommand(...);
...
insertLib.Dispose();
}
that makes it perfectly clear the OleDbCommand is always created, used, disposed.
I am not familiar with some of the classes you are using (e.g. ID3Info), chances are they also have a Dispose() and need the same treatment.
ADDED
There is a useful construct that automates the above, like so:
foreach (...) {
using (OleDbCommand insertLib=new OleDbCommand(...)) {
...
}
}
The advantages are it takes less code, and the Dispose is guaranteed to occur, even when an exception gets thrown inside the using block.
/ADDED
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Wednesday, March 11, 2009 8:43 PM
|
|
|
|
|
I assume that the ID3info class (not shown) opens the file from the supplied parameters.
CurrSong = new ID3Info(filepaths[i], true);
If you have access to this classes code, make sure that the stream is disposed, if not, check to see if it has a Close or Dispose method. That might mean moving the
ID3Info CurrSong; inside the foreach loop.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
On a minor note... you have
foreach(string str in filepaths) then
path = filepaths[i].ToString(); The path field is unecessary, you can just use str in it's place.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I have brought the declarations inside the loop, removed the System.GC.Collect and put in the insertLib.dispose(). The ID3Info class has no dispose or close method. Running the code now doesnt get me as far as with System.GC.Collect.
|
|
|
|
|
Check out Luc's added note to his previous post about wraping in a using block.
That might be the answer to the ID3Info as well (if that's the culprit). You can have nested using blocks
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Works for the OleDbCommand but not the ID3Info
It give s me this
'ID3.ID3Info': type used in a using statement must be implicitly convertible to 'System.IDisposable'
|
|
|
|
|