inject the "break;" into your foreach statement string ejvqry = string.Empty; var query = from frstqry in dsquery.Tables[0].AsEnumerable() select new { frstqrystring = frstqry.Field<string>("appendqry") }; foreach (var fixedqry in query){ ejvqry = fixedqry.frstqrystring; break; } Reference: http://www.programlive.tk have some C# simple example code here
MasttsaM
Posts
-
How to get single value from linq query without using loop -
Editable GridViewYou can reference this example: protected void gv4PPdata_RowDataBound(object sender, GridViewRowEventArgs e) { if((e.Row.RowState & DataControlRowState.Edit) > 0) { TextBox curText; for (int i = 1; i <= 6; i++) { curText = (TextBox)e.Row.Cells[i].Controls[0]; curText.Width = Unit.Pixel(60); if (i == 1) { curText.Enabled = false; } } } } Reference: http://www.programlive.tk
-
Need help with my very first c# applicationHope this example can help you: Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; if (p.Start()) { p.StandardInput.WriteLine("net use " + strFileName + " " + strPwd + " /user:" + strDomain + "\\" + strId); p.StandardInput.WriteLine("exit"); p.WaitForExit(); string ReturnText = p.StandardOutput.ReadToEnd(); if (ReturnText.IndexOf("成功") >= 0) Dts.TaskResult = (int)ScriptResults.Success; else throw new Exception("fail"); } else throw new Exception("fail"); Reference: http://www.programlive.tk
-
Dos CommandProcess p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; if (p.Start()) { p.StandardInput.WriteLine("net use " + strFileName + " " + strPwd + " /user:" + strDomain + "\\" + strId); p.StandardInput.WriteLine("exit"); p.WaitForExit(); string ReturnText = p.StandardOutput.ReadToEnd(); if (ReturnText.IndexOf("成功") >= 0) Dts.TaskResult = (int)ScriptResults.Success; else throw new Exception("fail"); } else throw new Exception("fail"); Refrence: http://www.programlive.tk
-
Retrieving a DataTable from a Collection by name:) ds = DB.FillDataSet(cmd, "StRecord"); GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); foreach (DataColumn col in ds.Tables[0].Columns ) { } From: http://www.programlive.tk