Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. dataGrid and textBox

dataGrid and textBox

Scheduled Pinned Locked Moved C#
databasesql-serversysadminquestion
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aPerfectCircle
    wrote on last edited by
    #1

    I can display results of a view I created in Sql server on a dataGrid,how would I display the same result on a txtBox ???

    aPerfectTool

    F M A 3 Replies Last reply
    0
    • A aPerfectCircle

      I can display results of a view I created in Sql server on a dataGrid,how would I display the same result on a txtBox ???

      aPerfectTool

      F Offline
      F Offline
      freshonlineMax
      wrote on last edited by
      #2

      Hi I think you want to access database tables field to show in textbox. If below code is not your answer contact me: SqlConnction cnn = new SqlConnection("Data Source=YourCopmputerName;Initial Catalog=YouDatabaseName;User Id=databaseUserName;Password=DatabasePassword"); string strSql="SELECT id,name FROM Table1"; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(strSql,cnn); da.fill(ds,"Table1"); if (ds.Tables[0].Rows.Count != 0) { TextBox1.Text = ds.Tables[0].Rows[0][1].toString(); } This code get "name" column of tables from first row. you can access another cells by changing array index. Bye

      1 Reply Last reply
      0
      • A aPerfectCircle

        I can display results of a view I created in Sql server on a dataGrid,how would I display the same result on a txtBox ???

        aPerfectTool

        M Offline
        M Offline
        mkc2k3
        wrote on last edited by
        #3

        Hi, I think U can achieve this in two ways. 1) Command.Text = "SELECT * FROM UR View Name (Nested of Table Name)" 2) Create one store Proc, Let the Store Proc intern selects view data by executing SELECT * FROM UR View Name. For binding and displaying on Data Grid follow normal method.

        Happy Coding Gowda

        1 Reply Last reply
        0
        • A aPerfectCircle

          I can display results of a view I created in Sql server on a dataGrid,how would I display the same result on a txtBox ???

          aPerfectTool

          A Offline
          A Offline
          aPerfectCircle
          wrote on last edited by
          #4

          Thanks guys, I got it going, your reponse helped me alot :|

          aPerfectTool

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups