Search Results

Search found 2 results on 1 pages for 'chuki2'.

Page 1/1 | 1 

  • Multiple fields from LINQ to Text Box

    - by Chuki2
    how can I pass value from selected field (LINQ) to textbox in winforms? If single fields, I just do like this var result = from row in dtValueBranch.AsEnumerable() where row.Field<int>("branchID") == idBranch select row.Field<string>("branchName"); StringBuilder sb = new StringBuilder(); foreach (string s in result) { sb.Append(s + Environment.NewLine); } tbBranch.Text = sb.ToString(); So this is the code LINQ to many fields var result = from row in dtValueBranch.AsEnumerable() where row.Field<int>("branchID") == idBranch select new { BranchName = row["branchName"].ToString(), branchTel = row["branchTel1"].ToString(), // And many more fields }; How can I to implement each fields to each textbox?

    Read the article

  • Value is zero after filter SQL in C#

    - by Chuki2
    I`m new in C#.. I have write function to filter department. And this function will return idDepartment. New problem is, department keep value "System.Windows.Forms.Label, Text : ADMIN ", that`s why i got zero. So how can i take "ADMIN" only and keep to department? Update : public partial class frmEditStaff : Form { private string connString; private string userId, department; //Department parameter coming from here private string conString = "Datasource"; public frmEditStaff(string strUserID, string strPosition) { InitializeComponent(); //Pass value from frmListStaff to userID text box tbStaffId.Text = strUserID.ToString(); userId = strUserID.ToString(); department = strPosition.ToString(); } This code below is working, don`t have any problem. public int lookUpDepart() { int idDepart=0; using (SqlConnection openCon = new SqlConnection(conString)) { string lookUpDepartmenId = "SELECT idDepartment FROM tbl_department WHERE department = '" + department + "';"; openCon.Open(); using (SqlCommand querylookUpDepartmenId = new SqlCommand(lookUpDepartmenId, openCon)) { SqlDataReader read = querylookUpDepartmenId.ExecuteReader(); while (read.Read()) { idDepart = int.Parse(read[0].ToString()); break; } } openCon.Close(); return idDepart; } } Thanks for help. Happy nice day!

    Read the article

1