|
hi,
does anyone know how to change the standardprinter in a .net application?
thanks
michael
ps:
my concret problem is that i use the acrobat pdf-control to display a pfd in my application. ich even can print it with the "printAll()" methode on the standardprinter. but i found no way to set the printer the document should be printed. i even would be thankfull for a tipp to change the sprinter-settings in the pfd-control ;o)
|
|
|
|
|
Hi folks,
I´m building a database application, which has to connect to a database through an ODBC provider, but when I insert an OleDbDataAdapter in my form, and try to "connect" it with any ODBC data source, I get a nasty message telling me that the data source and the adapter are not compatible.
If I choose another OleDB provider, such as Microsoft Jet driver it works fine.
The question is: ¿do I need any kind of special code/libraries to get data from ODBC sources?.
Thanks in advance.
|
|
|
|
|
What does your ConnectionString look like? Can you also post what excatly the error message says?
-------------------------------
Joan
MomComputerGeek.com
|
|
|
|
|
The ConnectionString of my connection is:
"Provider=MSDASQL.1;Persist Security Info=False;Data Source=Base de datos de ejemplo Xtreme;Extended Properties="DSN=Base de datos de ejemplo Xtreme;DBQ=C:\Archivos de programa\Microsoft Visual Studio .NET\Crystal Reports\Samples\Database\es\xtreme;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;";Initial Catalog=C:\Archivos de programa\Microsoft Visual Studio .NET\Crystal Reports\Samples\Database\es\xtreme"
And I get this error message:
"La conexión que acaba de crear no funciona con el adaptador actual"
In english:
"The connection you´ve just created doesn´t work with the current adapter"
Maybe I need some patch or update for my VS copy.
"When I look into your eyes, there´s nothing there to see, nothing but my own mistakes staring back at me"
|
|
|
|
|
If you're using Framework 1.0 and VS.NET 2002, you'll need to download the ODBC.NET Data Provider[^].
If you're using Framework 1.1 and VS.NET 2003, then you just need to use the System.Data.Odbc namespace.
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
Here's part of my project:
public class NetworkStats
{
private Form1 form;
private AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer player;
private ConfigResult cf;
public NetworkStats(Form1 form1, AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer player1, ConfigResult cf1)
{
form = form1;
player = player1;
cf = cf1;
}
public FileStruct FileStats()
{
string path;
DirectoryInfo dir;
FileStruct fs = new FileStruct();
path = cf.pathLog + "\\" + player.currentMedia.name + "\\";
dir = new DirectoryInfo(cf.pathLog);
dir.CreateSubdirectory(player.currentMedia.name);
if(cf.buffCount)
{
try
{
fs.fileStats = new FileStream(path + "Stats.txt", FileMode.Create, FileAccess.Write);
fs.swStats = new StreamWriter(fs.fileStats);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
if(cf.currBW)
{
try
{
fs.fileBW = new FileStream(path + "currBW.txt", FileMode.Create, FileAccess.Write);
fs.swBW = new StreamWriter(fs.fileBW);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
if(cf.currBR)
{
try
{
fs.fileBR = new FileStream(path + "currBR.txt", FileMode.Create, FileAccess.Write);
fs.swBR = new StreamWriter(fs.fileBR);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
if(cf.currFR)
{
try
{
fs.fileFR = new FileStream(path + "currFR.txt", FileMode.Create, FileAccess.Write);
fs.swFR = new StreamWriter(fs.fileFR);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
return fs;
}
public void initStats()
{
FileStruct fs;
fs = FileStats();
while (Form1.videoParat != true)
{
try
{
form.BitRate.Text = (player.network.bitRate).ToString() + " Bps";
if(cf.currBR)
{
fs.swBR.WriteLine(player.network.bitRate.ToString() + " " + player.controls.currentPositionString);
}
form.BW.Text = (player.network.bandWidth).ToString() + " Bps";
if(cf.currBW)
{
fs.swBW.WriteLine(player.network.bandWidth.ToString() + " " + player.controls.currentPositionString);
}
form.buffCount.Text = (player.network.bufferingCount).ToString();
form.buffProgress.Text = (player.network.bufferingProgress).ToString();
form.buffTime.Text = (player.network.bufferingTime).ToString() + " mseg";
form.downProgress.Text = (player.network.downloadProgress).ToString() + " %";
form.currentFR.Text = (player.network.frameRate).ToString() + " FPS";
if(cf.currFR)
{
fs.swFR.WriteLine(player.network.frameRate.ToString() + " " + player.controls.currentPositionString);
}
form.encodFR.Text = (player.network.encodedFrameRate).ToString() + " FPS";
form.framesSkip.Text = (player.network.framesSkipped).ToString();
form.lostPackets.Text = (player.network.lostPackets).ToString();
form.rxQuality.Text = (player.network.receptionQuality).ToString();
form.sourceProtocol.Text = (player.network.sourceProtocol);
form.rxPackets.Text = (player.network.receivedPackets).ToString();
form.recoveredPackets.Text = (player.network.recoveredPackets).ToString();
form.maxBW.Text = (player.network.maxBandwidth).ToString() + " Bps";
fs.swStats.WriteLine("prova");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
//escriure la resta d'estadístiques
try
{
fs.swStats.WriteLine("prova 2"); <--------
fs.swBR.WriteLine("prova");
fs.swStats.WriteLine("prova 3");
fs.swBW.WriteLine("prova");
fs.swStats.WriteLine("Buffering Count: ");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Console.WriteLine(e.Message);
}
fs.Close();
}
}
public class FileStruct
{
public FileStream fileBW;
public StreamWriter swBW;
public FileStream fileBR;
public StreamWriter swBR;
public FileStream fileFR;
public StreamWriter swFR;
public FileStream fileStats;
public StreamWriter swStats;
public void Close()
{
try
{
swBW.Close();
swBR.Close();
swFR.Close();
swStats.Close();
fileBW.Close();
fileBR.Close();
fileFR.Close();
fileStats.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
The problem is that when arrives to "fs.swStats.WriteLine("prova 2");" it gets the "object reference..." exception, and I can't write anything to the output file....I really don't know what to do!!!
Please, if anyone has any idea, I'd be really grateful!!!!
|
|
|
|
|
Well, I would guess that, since you only create the swStats member when cf.buffCount is true, cf.buffCount is false.
Your best bet is to use the debugger to trace through your application. Check that swStats is being created properly, and if it is what else is happening as your app runs.
Also, I would define a new class that encapsulates the "create a filestream, create a stream writer" code. You're replicating it several times.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Thank you very much!! I think I've found the problem, although is not about cf.buffCount. You're right, I'll encapsulate this function into another class, thank you very much!
|
|
|
|
|
As title,
I am a C++ programmer so dont need a book that is too much geared for new programmers.
Are there any other books I should look at ?
I want to make use of the 50% off on this title at amazon.co.uk if it is any good
|
|
|
|
|
|
That link seems to point to "Help: Object reference not set to an instance of an object"
If it was meant to point to "Looking for a good book on C#", then I really want to know about C# Unleashed as it is enjoying a 50% off offer
|
|
|
|
|
Ooooops,sorry I don't know why the link does not work correctlly.there is another thread like your question 8 question below yours.Check it,I don't know why the link does not work.
Mazy
No sig. available now.
|
|
|
|
|
How can I add a type derived from DataGridColumnStyle into the list in the DataGridColumnStyle Collection Editor dialog box (of the Properties dialog box)?
|
|
|
|
|
I have a contextmenu which I use & for charachter to set shortcut for users. Foe example it has a "&Hello" test.The problem is an underline is shown in design mode under 'H' , but at run time it does not appear.The event habdler fires when I press H but there is no underlinw at run time.Any idea?
Mazy
No sig. available now.
|
|
|
|
|
You might have Windows' setting turned on where it doesn't show the accelerator letters unless you press Alt. An easy way to tell is to put a MainMenu on your form and do the same thing. If at runtime you don't see the accelerator letters then you know this is the case. Press Alt to bring up the menu and then they'll be there.
James
At Jethro Tull's August 28, 2003 concert Ian Anderson mentioned that the group would be performing a medley of title tracks. The songs were "Songs from the Wood", "Too Old to Rock and Roll; Too Young to Die"; and from the Heavy Horses album, "Stairway to Heaven".
|
|
|
|
|
Oh ya.When I press Alt they apear. Where is this setting in windows?
Mazy
No sig. available now.
|
|
|
|
|
On WinXP Pro it's located under Display Properties, Appearance tab, Effects... button, uncheck "Hide underlined letters for keyboard navigation until I press the Alt key".
James
At Jethro Tull's August 28, 2003 concert Ian Anderson mentioned that the group would be performing a medley of title tracks. The songs were "Songs from the Wood", "Too Old to Rock and Roll; Too Young to Die"; and from the Heavy Horses album, "Stairway to Heaven".
|
|
|
|
|
Thanks James.
Mazy
No sig. available now.
|
|
|
|
|
Scenario:
Typed Tables Earnings, Projects, Adresses, Einheiten
DataSets: EarnSet (Earnings, Projects, Einheiten), ProjectSet(Projects)
For one Programm I need the Tables Earnings and Projects in one DataSet. For another Programm I need just the Table Projects. The Status is that now I have two DataSets: EarnSet with Earnings and Projects Tables and ProjectSet with only the Projects Table. So I have the same table-Definition in two different DataSets.
Is there a way to add the typed Table Projects from ProjectSet to the typed DataSet EarnSet so that after in the EarnSet the typed! Table Projects exists?
Stefan
|
|
|
|
|
1. I think it's impossible to have one table into two datasets
2. Try to use one dataset or copy table with data
Hi,
AW
|
|
|
|
|
i have a number of projects located within my solution (they are dlls (3)) i reference the project from my main project,and when the dlls are compiled they are put in the directory with the .exe the program works fine...but i want to move those dlls to a diffrent sub folder (/data or something you know ?) but the .exe cant locate them if i move them. How can i move them and still have the .exe locate them ?
thanks for your time.
Jesse M.
The Code Project Is Your Friend...
|
|
|
|
|
I see people doing this with VB, but I can't get it to work in C#.
<br />
System.Drawing.Imaging.ImageCodecInfo myImageCodecInfo;<br />
System.Drawing.Imaging.Encoder myEncoder;<br />
System.Drawing.Imaging.EncoderParameter myEncoderParameter;<br />
System.Drawing.Imaging.EncoderParameters myEncoderParameters;<br />
<br />
myImageCodecInfo = GetEncoderInfo("image/tiff");<br />
<br />
myEncoder = new System.Drawing.Imaging.Encoder(System.Drawing.Imaging.Encoder.Compression.Guid);<br />
<br />
myEncoderParameters = new System.Drawing.Imaging.EncoderParameters(1);<br />
<br />
myEncoderParameter = new System.Drawing.Imaging.EncoderParameter(myEncoder,<br />
:confused:System.Drawing.Imaging.EncoderValue.CompressionCCITT3<br />
);<br />
<br />
myEncoderParameters.Param[0] = myEncoderParameter;<br />
DestBitmap.Save(strFileName, myImageCodecInfo, myEncoderParameters);
The compiler insists that it doesn't know how to convert CompressionCCITT3 to byte . I don't know why EncoderValue isn't one of the overloads in the first place. If I manually cast it as byte, int, or long, I get an invalid parameter error from save. Does anybody know which one of the 16 overloads I'm supposed to use?
|
|
|
|
|
I apparently lost track of all my permutations. byte, short, and int all result in "invalid parameter" from save, but long appears to work. I almost forgot that the int and long are the same thing in mc++ but not c#.
Thanks anyway.
|
|
|
|
|
I have a datagrid, dataset, and sql server data source. I would like to be able to update my dataset through my datagrid. I thought binding the dataset to the datagrid would give me the ability to do this, but I guess I am wrong (I am new to C# and .NET). I have created a dataAdapter to update the datasource, but I would like to update the dataset first. Can any one help me get started here. What I have is a datagrid and would like to allow the user to do update, insert, and delete data then click a button that will sync the datagrid with the dataset. Any insight is appreciated.
|
|
|
|
|
Binding a Control to a DataTable or DataSet adjusts only Data in the DataSet NOT in the SQL-Server Table. That means that your input in your Datagrid will only change Data in the DataSet. You have to Update the Tables with the DataAdapter.Update(DataTable) / SqlDataAdapter.Update(...) Method.
So your Button to Update: SqlDataAdapter.Update(DataTable) /DataSet
DataTable dt=new DataTable("Table1");
..
..
SqlDataAdapter ada=new SqlDataAdapter(...);
ada.Update(dt);
Be aware of not to call DataSet.AcceptChanges/DataTable.AcceptChanges() before DataAdapter.Update()! because otherwise no data will be updated; after AcceptChanges all Rows are marked as unchanged and so the DataAdapter don't "find" Rows to Update! In the help files everywhere you can find
"AcceptChanges()" which is very irritating.
|
|
|
|