|
I m making an applicaiton that manages printing usin WMI calls. my appication looks like the queue similar to windows queu. There are 2 listboxes. 1 is showing printer name and the other is showing jobs associated with the selected printer in first listview.
on the selectedindex changed of listview1 i have filled listview2 the code for listview1 selected index changed is as follows:
string[] details = new string[12];
ListViewItem lv;
int i=0;
string a="";
Decimal size;
string submited_date;
try
{
a = this.listView1.SelectedItems[0].Text;
printername = this.listView1.SelectedItems[0].Text;
printerindex=this.listView1.SelectedItems[0].Index;
}
catch (Exception){}
try
{
this.listView2.Items.Clear();
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_PrintJob");
//listviewcolumes();
foreach (ManagementObject queryObj in searcher.Get())
{
System.String jobName = queryObj.Properties["Name"].Value.ToString();
char[] splitAr = new char[1];
splitAr[0] = Convert.ToChar(",");
string prntname = jobName.Split(splitAr)[0];
size = Convert.ToDecimal(queryObj["Size"].ToString());
string year = "";
string month = "";
string dates = "";
string hours = "";
string min = "";
string sec = "";
year = queryObj["TimeSubmitted"].ToString().Substring(0,4);
month = queryObj["TimeSubmitted"].ToString().Substring(4,2);
dates = queryObj["TimeSubmitted"].ToString().Substring(6,2);
hours = queryObj["TimeSubmitted"].ToString().Substring(8,2);
min = queryObj["TimeSubmitted"].ToString().Substring(10,2);
sec = queryObj["TimeSubmitted"].ToString().Substring(11,2);
//for (int x=0;x
|
|
|
|
|
Hi all,
I am developing a window application and have developed a menu. but i have to
add icons to menu items. pls tell me how this can be done. i am using c#.
Praveen.
|
|
|
|
|
|
You have answered your own question, actually.
If you create a boolean property inside a user control and then add the user control into a form (should be visible in the designer mode), then you can see the property in the Property Page of VS.NET editor.
There has to be more to life than just this
|
|
|
|
|
Hi,
I am a newbie to C# and Im trying to redirect standard input, output and error of a console program written in C (MS VC 6.0) to a textbox on a form. The code for the redirecting looks like this:
private System.IO.StreamWriter c_StreamInput = null;
private System.IO.StreamReader c_StreamOutput = null;
private Thread c_ThreadRead = null;
private Process c_Process = null;
private void ReadStdOutputThreadProc()
{
try
{
string str = c_StreamOutput.ReadLine();
while(str != null)
{
txtboxCNF.AppendText(str+"\r\n");
Thread.Sleep(100);
str = c_StreamOutput.ReadLine();
}
}
catch(Exception) {}
}
private void btnStart_Click(object sender, System.EventArgs e)
{
if(c_Process == null)
{
c_Process = new Process();
ProcessStartInfo psi = new ProcessStartInfo("console.exe");
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
c_Process.StartInfo = psi;
c_Process.Start();
c_StreamInput = c_Process.StandardInput;
c_StreamOutput = c_Process.StandardOutput;
c_StreamInput.AutoFlush = true;
c_ThreadRead = new Thread(new ThreadStart(ReadStdOutputThreadProc));
c_ThreadRead.Start();
}
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (c_ThreadRead != null)
{
c_ThreadRead.Abort();
c_ThreadRead.Join();
}
if(c_Process != null && !c_Process.HasExited)
c_Process.Kill();
}
The console application that I am trying to run (console.exe) is a simple C program that prints a line text and then calls the getchar() function. The code is basically this:
#include "stdafx.h"
#include
int main(int argc, char* argv[])
{
printf ("Hello World !!\n");
int ch = getchar();
printf("Character = %s\n", ch);
return 0;
}
I have tried to run the C program without the getchar() function and it works. The problem arises when I use the getchar() function. I have tried getch() and gets() version without any success. I am not sure if I have to do anything special for showing output when using such functions.
Any help/pointers in this direction will be greately appreciated.
Thanks in advance.
Dribble
|
|
|
|
|
Ok should be a simple question as I didn't do research at all. (I'm tired, and been working all 15 hours on a coding project.) I would just like to know if there are any differences as far as connectors, queries and other coding related statements from SQL to MySQL. I am currently using MySQL to test the program, am I going to run into problems when making the final switch to SQL?
Thanks for all the help!
|
|
|
|
|
Hello,
If i am not mistaken, most probably you are asking about differece of queries between these two database engines.
If so, then here is my opinion.
The queries of MySQL is really different than SQL queries. Only very common queries will be same like, SELECT * FROM tableName, UPDATE tableName set ... etc., other than that, SQL queries are less forgiving than MySQL. In mySQL, joining table (inner join) , no need to mention in queries, like,
SELECT tableA.fieldA, tableB.fieldC from tableA,tableB WHERE tableA.id = 5 AND tableA.foriegnKey = tableB.primaryKey
But in SQL, you will have to use InnerJoin , ON etc phrase .
I know about parameters in SQL is @variable, in Access is , variable = ? , I dont know if mySQL has any parameter syntax to use in C#, as I used mySQL with PHP, not with anything else.
|
|
|
|
|
Thank you, usually I just use SQL, this time I am programming from home where I don't have access to a SQL server. Again, thanks for the quick response.
|
|
|
|
|
|
I understand, that this is simple question for peoples who work with C# some time. But there is the question: I create Windows forms dll in C# and I have to store bmp jpg files in this dll - not located as image in disk, but included in one dll file. Embedded resources or something? Please give me a tip.
|
|
|
|
|
|
Thanks - it was very fast
|
|
|
|
|
Hey howzit?
I have a Panel that displays 3 different photos as BackGroundImage's. One is 300dpi, 150dpi and 72dpi. Each photo causes the Panel to autosize.
I am using this as a zoom mechanism. So when the user clicks zoom, the image changes from 72dpi to 150dpi and 150dpi to 300dpi and that works fine, BUT i want the the scrollpositions of the form to change so that the area where the cursor is located on the image, is displayed in the middle. Similar to how we zoom to a specific spot in MS Word, i have used the code below but it doesn't seem to be very acurate, perhaps there is a way to achieve this specific position zoom in another way?
form.AutoScrollPosition = Cursor.Position;
Thanks!
|
|
|
|
|
Respected sir
my name is vivek deshpande.
i want to build one application in visual C#.net.
i know ADO.NET connectivity in Excel and also Access.
i want to transfer data from excel sheet to access table.
column name may be different.
for example in excel suppose their are fields such studName,studAddress
and in access fields such as Name,Address
then all data from studName should be transfer to Name in access database.
also all data from studAddress should be transfer to Address in access database.
if both database are very large then form size should be vary
we should map it automatically.
please tell me how to do this.
if any code available on net then tell me.
i hope u provide best solution in C# code as early as possible.
have a good day
yours
Vivek Deshpande
|
|
|
|
|
hi..
This is the same task what am too doing..
First,Do get the schema information of Source and then the data....
Now fetch the mapped columns data and schema....
In case of Access to Excel..Fetch the range of the target(excel) against which your source data is to be transferred and then set the Format of the cells depending upon the source column's datatype(if needed alone)..
Then use the usual adapter's Update(DataTable) to update ur Target database by using the datatable which contains the source table data....
If this is your need,feel free to askme further queries...
Hope you could have got atleast a small idea of what u have to do...
|
|
|
|
|
Hi friend,
The coding part is little vast since am using it in my project...
Anyway,i'll try my best to cut-short it and send you...
Also,a kind request,let ur responses and reply be sent to Codeproject site..'coz there may be many people who are like us searching for a solution...May be,the ideas we share help them...
Keep trying...
All the best
|
|
|
|
|
I have two classes, one running on a seperate thread. The one class writes to a table in a database and the other reads and writes to the same table in the database.
The class that only writes to the table is on a seperate thread.
The class that reads and writes to the table is on a timer. So every 5seconds it checks a boolean value and if its true it updates a listview.
The problem comes in when both classes tries to access the table at the same time, I get an error that the connection is currently open and busy.
How can I lock the method that loads the data from the table until the one class is finished.
Then the other problem will be. The main idea behind this is that two machines running the same app can use one database. how do I check if the other machine is currently busy on that table?
Any help and ideas will be appreciated.
Thanks in advance
|
|
|
|
|
What about using different connection instance of Connection class !!
i.e,
SqlConnection myConnection1 = new SqlConnection(.....);
SqlConnection myConnection2 = new SqlConnection(....);
Now, use myConnection1.Open() , myConnection1.Close() ...etc in One thread,
use myConnection2.Open(), myConnection2.Close() ....etc in another thread,
I am just thinking, I did not test it.
|
|
|
|
|
|
Please let me know if that solution is working. Because one of my current project will need simultaneous operation on a SQL file from two different thread, and I have just developed this algorithm.
-- modified at 1:43 Thursday 23rd February, 2006
|
|
|
|
|
lock(x)
{
DoSomething();
}
What the lock statement does is wrap an object known as a mutual exclusion lock, or mutex, around the variable in the round brackets. the mutex will remain in place while the compound statement attached to the lock keyword is executed. While the mutex is wrapped around a variable, no other thread is permitted access to that variable. If the next thread to gain to gain the time slice attempts to access the variable x, acceess to the variable will be denied. Instead, Windows will simply put the thread to sleep until the mutex has been released.
The above was quoted from "Professional C# 3rd Edition". They also say you must just be aware of deadlocks
Hope that helps you, works perfectly for what I need.
|
|
|
|
|
lock(x) is great, but in your case you should be allowing the database to decide locking, and use 2 connection instances.
|
|
|
|
|
Hi,
In my C# Windows application, I am using so many gifs and jpgs from various website. Say like for Search Button, I searched in Google Image search and found some small search icons, I just downloaded and used. Now Is there any copyright problem I may face When I will publish this software for retail distribution ? Or may any one sue me just to use those images ?
Emran
|
|
|
|
|
Hi!
Yes, you could run into copyright issues there.
You should assume that every image you find on Google image search is copyrighted by the owner and that you are not allowed to freely use it.
I guess some standard icons (for example, those usually used for save, cut/copy/paste, new document, etc.) can be used freely, but I can't draw a precise line what's ok and what isn't.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
No one can draw a precise line, as this is different from country to country.
|
|
|
|
|