标题:请大家帮帮忙!
取消只看楼主
Freeness
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2007-11-25
 问题点数:0 回复次数:1 
请大家帮帮忙!
怎么才能把sqlcommand中的sql语句查询出来的结果放到textbox中去 比如这样个例子
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace 查询
{
    class Program
    {
        static void Main(string[] args)
        {
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = "Data Source=WWW-2568B4977E8\\FREENESS;Initial Catalog=Exercise;Integrated Security=true";
            connection.Open();
            SqlCommand cmd = new SqlCommand("select * from Friend", connection);
            SqlDataReader myReader = cmd.ExecuteReader();
            到这边都没问题 接下来是怎么把sqlcommand中查的数据放到textbox中啊
        }
    }
}
搜索更多相关主题的帖子: using System connection FREENESS Data 
2008-03-09 21:07
Freeness
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2007-11-25
得分:0 
晕 发错了 上面那个是控制台的程序 应该是这个
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = "Data Source=WWW-2568B4977E8\\FREENESS;Initial Catalog=Exercise;Integrated Security=true";
            connection.Open();
            SqlCommand cmd = new SqlCommand("select * from Friend", connection);
            SqlDataReader myReader = cmd.ExecuteReader();
            //这边textbox应该怎么写?
        }
    }
}
2008-03-09 21:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-202695-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.532887 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved