分享

c#+sql

 秋寒月 2010-11-29

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 WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        private static string ConnectionString = "Data Source=MICROSOF-44BEF0;Initial Catalog=追踪;user id=sa;password=zzw848686;";
        private SqlConnection conn = null;
        private SqlCommand cmd = null;
        private SqlDataAdapter sda = null;
        private DataSet ds=null;

        public Form1()
        {
            InitializeComponent();
            conn = new SqlConnection(ConnectionString);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (conn.State != ConnectionState.Open)
                conn.Open();
            try
            {
                string sql = "select * from Tracker";
                DataSet ds = new DataSet();
                cmd = new SqlCommand(sql, conn);
                cmd.ExecuteNonQuery();
                sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                sda.Fill(ds);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    double x = 0;
                    x = Convert.ToDouble(ds.Tables[0].Rows[i]["Latitude"]);
                    string sx = Convert.ToString(x);
                    MessageBox.Show(sx);
                }
               
                //sda = new SqlDataAdapter();
                //sda.SelectCommand = cmd;
                //sda.Fill(ds);
                //dataGridView1.DataSource = ds.Tables[0];             
            }
            catch
            {

            }
        }

}

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多