本文介绍了我没有得到任何错误。但我没有在数据集中得到任何东西。无法使用sqlserver 2008和visual studio 2010查看results.im的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFirstsample
{
    public partial class Form1 : Form
    {
        private SqlConnection cn;
       
        private SqlDataAdapter da;
        private SqlCommand cmd;
        private DataSet ds;
        private string strcon;
        private string strq;
        private int icounter;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            strcon="Data source=.;Initial Catalog=school;Integrated security=true; ";
            
            cn = new SqlConnection(strcon);
            strq = "select * from student";           
            da = new SqlDataAdapter(strq,cn);
            ds = new DataSet();
            da.Fill(ds);
            textBox1.Text = ds.Tables[0].Rows[0]["id"].ToString();
            textBox2.Text = ds.Tables[0].Rows[0]["name"].ToString();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
           // MessageBox.Show("hi");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            icounter = 0;
            textBox1.Text = ds.Tables[0].Rows[icounter]["id"].ToString();
            textBox2.Text = ds.Tables[0].Rows[icounter]["name"].ToString();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            int irowcount = ds.Tables[0].Rows.Count - 1;
            if (icounter < irowcount)
            {
                icounter++;
                textBox1.Text = ds.Tables[0].Rows[icounter]["id"].ToString();
                textBox2.Text = ds.Tables[0].Rows[icounter]["name"].ToString();
            }
            else
            {
                MessageBox.Show("you are already on the last record");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (icounter > 0)
            {
                icounter--;
                textBox1.Text = ds.Tables[0].Rows[icounter]["id"].ToString();
                textBox2.Text = ds.Tables[0].Rows[icounter]["name"].ToString();
            }
            else
            {
                MessageBox.Show("you are already on the first record");
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            icounter = ds.Tables[0].Rows.Count - 1;
            textBox1.Text = ds.Tables[0].Rows[icounter]["id"].ToString();
            textBox2.Text = ds.Tables[0].Rows[icounter]["name"].ToString();
        }
    }
}

推荐答案

这篇关于我没有得到任何错误。但我没有在数据集中得到任何东西。无法使用sqlserver 2008和visual studio 2010查看results.im的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 08:10