I am working on Visual Studio using C#. I need to get data from different database tables in SQL server into text boxes onto the Visual Studio form. The database tables have several rows and columns. The values are real values. I am using the code below. I don’t get the data to text boxes. Can anyone please help? Thanks. What I have tried: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Text.RegularExpressions; using System.Data.SqlClient; using System.Configuration; using System.Data.Common; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=192.146.1.5,1433;Network Library=DBMSSOCN;Initial Catalog=Estimator;User ID=id;Password=password;Trusted_Connection=True"); con.Open(); SqlCommand cmd = new SqlCommand("select * from Table1", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { textBox1.Text = dr.GetString(0); textBox2.Text = dr.GetString(1); textBox2.Text = dr.GetString(2); } con.Close(); } } }
Double
String.Format()
variable.ToString()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)