|
May be something like this will help:
StringBuilder returnValue = new StringBuilder();
Process P = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Codegen.exe";
p.StartInfo.Arguments = open.FileName + " 10 30";
p.Start();
p.OutputDataReceived += (o, e) =>
{
if (e.Data != null)
returnValue.AppendLine(e.Data);
};
p.ErrorDataReceived += (o, e) =>
{
if (e.Data != null)
returnValue.AppendLine(e.Data);
};
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
if (returnValue.Length > 0)
{
standardOutput = returnValue.ToString();
}
|
|
|
|
|
Harsh, thanks so much as this now works. I cant explain the difference between
p.OutputDataReceived += (o, e) =>
{
if (e.Data != null)
returnValue.AppendLine(e.Data);
};
and what I tried before which was using a separate handler assigned to OutputDataReceived.
Is your code different from
sortProcess.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler);
private static void SortOutputHandler(object sendingProcess,
DataReceivedEventArgs outLine)
{
}
However your code works so thanks very much
Regards
Ray
|
|
|
|
|
I am glad that it worked for you.
Basically your code and mine is almost same. While your code is creating explicitly named event handler, mine creates anonymous function.
I think the difference is that I am capturing the stdErr output to the string variable as well.
|
|
|
|
|
i want to show the selected cheakbok values from one grid view to another grid view in windows form.
|
|
|
|
|
Fine, that is what you want to do, but you will need to explain in more detail why you cannot do it.
|
|
|
|
|
private void cheakbox_Load(object sender, EventArgs e)
{
con = new SqlConnection("Data Source=(local);Initial Catalog=vediocon;Integrated Security=True");
con.Open();
string s = "Select Date,DealerCode,AmounTransfer,ActualAmount,TransactionCode from [Transaction]where TransactionType='PBT' order by TransactionId desc";
cmd = new SqlCommand(s, con);
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
dataGridView1.DataSource = dt;
DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(chk);
chk.HeaderText = "Check Data";
chk.Name = "chk";
// dataGridView1.Rows[0].Cells[1].Value = true;
}
private void btnupload_Click(object sender, EventArgs e)
{
int RowNo = 0;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
RowNo = RowNo + 1;
bool Checkbox = ((CheckBox)row.FindControl("CheckBox1")).Checked;
if (Checkbox = true)
{
// Perform copy...
}
}
Logic to seclect the row..i m new so help me in this..thnks in advance!!
|
|
|
|
|
Keshav Shivhare wrote: // Perform copy. You need a reference to the other DataGridView, and you know the row and column,
so it's just a matter of setting the checkbox in that grid to the correct value.
|
|
|
|
|
i have done by using temp table..but i want to directly in the gridview...can you send me sample code.
|
|
|
|
|
In Datagridview you can use CellClick event and CellContentClick.Usign this event you can get the current clicked cell value and check for your checkbox checked.if its checked you can set the value to another datagridview.
Check my article related to datagridview helperclass.hope it might usefull for you.
DataGridView-Helper-Class
|
|
|
|
|
private void btnupload_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[5].Value!=null)
{
if ((Boolean)row.Cells[5].Value == true)
{
con = new SqlConnection("Data Source=(local);Initial Catalog=vediocon;Integrated Security=True");
con.Open();
string s = "insert into Temptransaction (date,dealercode,amounttranfer,actualamount,transactioncode)values'" + row.Cells[1].ToString() + "','" + row.Cells[2].ToString() + "','" + row.Cells[3].ToString() + "','" + row.Cells[4].ToString() + "','" + row.Cells[5].ToString() + "'";
cmd = new SqlCommand(s, con);
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
query in which i m trying to extract the though cell value and store in the temp table gives the error.
|
|
|
|
|
|
I think you have missed the ( and ) after insert values in your query
check your code
string s = "insert into Temptransaction (date,dealercode,amounttranfer,actualamount,transactioncode)values'" + row.Cells[1].ToString() + "','" + row.Cells[2].ToString() + "','" + row.Cells[3].ToString() + "','" + row.Cells[4].ToString() + "','" + row.Cells[5].ToString() + "'";
cmd = new SqlCommand(s, con);
This should be like this try this hope this will solve your problem.
string s = "insert into Temptransaction (date,dealercode,amounttranfer,actualamount,transactioncode) values ('" + row.Cells[1].ToString() + "','" + row.Cells[2].ToString() + "','" + row.Cells[3].ToString() + "','" + row.Cells[4].ToString() + "','" + row.Cells[5].ToString() + "')";
cmd = new SqlCommand(s, con);
|
|
|
|
|
Your code is vulnerable to SQL Injection[^].
NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
using (SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=vediocon;Integrated Security=True"))
using (SqlCommand cmd = new SqlCommand("insert into Temptransaction (date, dealercode, amounttranfer, actualamount, transactioncode) values (@date, @dealercode, @amounttranfer, @actualamount, @transactioncode)", con))
{
cmd.Parameters.AddWithValue("@date", row.Cells[1]);
cmd.Parameters.AddWithValue("@dealercode", row.Cells[2]);
cmd.Parameters.AddWithValue("@amounttranfer", row.Cells[3]);
cmd.Parameters.AddWithValue("@actualamount", row.Cells[4]);
cmd.Parameters.AddWithValue("@transactioncode", row.Cells[5]);
con.Open();
cmd.ExecuteNonQuery();
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hskjhsdfjkhdsfkjhsdklfhsodfhsdifhdsifh
|
|
|
|
|
Hello, guys
i want to create windows signup appliaction in c#.
i have a Html code of signup page.
from that code i want to create
signup app.
it must be include
3 textboxes:
1. username, 2. password, 3.captcha text
1 picrureBox for load captcha
1 refresh captcha button
1 submit button
i have this html code :
[code]
<title>MAD
USERNAME
PASSWORD
CAPTCHA
var dids = ["MIDP","ANDROID","WINDOWS","BlackBerry","SYMBIAN","MAC","WP","LINUX","IPHONE","WM"];
var curdid = 0;
function createCaptcha()
{
var chars ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ"
+ "abcdefghiklmnopqrstuvwxyz";
var str = "";
for (var i=0; i<10; i++)
{
str += chars[ Math.floor( Math.random() * chars.length ) ];
}
var form = document.getElementById("cI");
form.s.value = str;
document.getElementById("CAPTCHA").src =
'http://register.nimbuzz.com/init?w=120&h=40&f=png&s=' + str;
form.did.value = dids[curdid];
curdid = ( curdid + 1 ) % dids.length;
}
// generate initial CAPTCHA strings:
createCaptcha( );
document.getElementById("regen").onclick = createCaptcha;
[/code]
|
|
|
|
|
Is this Windows or Web application? If Windows, it is a simple matter to create a Windows Form with the controls you need. If it is Web you already have the code.
|
|
|
|
|
To add to Richard's question: if this is not a web-based project, what is it: C# WinForms, or WPF; C++ ?
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
I have a ListView set to use Detail mode.
Does C# allow me set a tool-tip for each individual SubItem of a ListViewItem and also allow me to detect a double-click or right-click for each individual SubItem?
Thanks
-Mike
|
|
|
|
|
Yes.
- Handle the
MouseDoubleClick event on the list view.
- Call
ListView.HitTest() to determine the target item and subitem. /ravi
|
|
|
|
|
Thanks Ravi
|
|
|
|
|
hi all !
I want to make a simple windows store application where i can stream video comming from my webcam (and from a local video file)
my question is how to capture video through a webcam and seed it over the network (localhost for exemple) , and how to connect and watch the streaming video
|
|
|
|
|
Message Closed
modified 2-Jan-15 2:24am.
|
|
|
|
|
|
I have an ASP .NET 2.0 application and am trying to add an assemble written in .NET 3.5; however, when I add the reference it appears in the references list with the dll.Refresh extension. Next, in the application the namespace is not recognized. Please help.
|
|
|
|
|
You can't add an assembly that is targeted at a higher version of the framework than the version your app is targeting: it won't be able to run the in the real world as the framework installed could well be V2.0 - and the V3.5 assembly can;t work under that.
Either recompile the referenced assembly under V2.0, or change your main application target to at least V3.5
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|