zoukankan      html  css  js  c++  java
  • linux mono 调用windows sqlServer 2005

    1.         实现linux mono Develop中调用windows 中的ql Server 2005

     


    linux windows 在一个局域网的网段中

    windows 中安装 sql Server 2005

    2.         windows 中的设置

    sql sever 2005 northwin数据库

    1.1 product结构

    jm4.jpg

     

    1.2 Categories 结构

    jm3.jpg

     

    2 如果本机的防火强开启,请关闭。如果防火墙开启,windows会阻止linux的访问


     

     

    3.         Linux中的设置

    3.1 Ping windows IP ,确认linux 可访问windows

     

     

     

    3.2 界面设计

    3.2.1 数据与PropertyGrid绑定界面

     

    JM1.jpg

     

    3.2.2 数据与gridView绑定界面

    jm2.jpg

     

     

     

    3.3 代码

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    using System.Data.SqlClient;

     

    namespace WinMonoApp

    {

        public partial class frmWFBrowse : Form

        {

            SqlDataAdapter myDataAdapter = null;

     

            //List<bindPropertyData> bindPropertyList = null;

     

            string myConnectionString = null;

     

            string sqlProduct = "SELECT * FROM [Northwind].[dbo].[Products] ";

     

            string sqlCategory = "SELECT [CategoryID],[CategoryName],[Description] FROM [Northwind].[dbo].[Categories] ";

     

          

     

            DataSet myCategory = new DataSet();

            DataSet myProduct = new DataSet();

     

            public frmWFBrowse()

            {

     

                InitializeComponent();

     

            }

     

     

     

            private void btnOK_Click(object sender, EventArgs e)

            {

     

                myConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WinMonoApp.Properties.Settings.BPMDBConnectionString"].ConnectionString;

     

     

     

                //MessageBox.Show(myConnectionString);

     

                myDataAdapter = new SqlDataAdapter(sqlCategory, myConnectionString);

     

              

     

     

     

                myDataAdapter.Fill(myCategory);

     

                myDataAdapter.SelectCommand.CommandText = string.Format(sqlProduct );

     

                myDataAdapter.Fill(myProduct);

     

     

     

                //MessageBox.Show(myDs.Tables[0].Rows.Count.ToString());

     

     

     

                this.FillTemplate();

     

            }

     

     

            private void FillTemplate()

            {

                try

                {

                  

                    if(myCategory.Tables.Count!=0)

                    {

                        this.lbTemplate.DisplayMember = "CategoryName";

                      

                        this.lbTemplate.DataSource = myCategory.Tables[0];

                    }

                }

                catch(Exception myEx)

                {

                    MessageBox.Show(myEx.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

     

            }

     

            private void lbTemplate_SelectedIndexChanged(object sender, EventArgs e)

            {

                var wfv = this.lbTemplate.SelectedItem as DataRowView ;

                if (wfv != null)

                {

                  this.llDeleteTemplate.Enabled = true;

               

                  this.pgTemplateV.SelectedObject = wfv;

     

     

                  DataRow[]  myProductList=myProduct.Tables[0].Select(string.Format("CategoryID={0}",wfv.Row.ItemArray[0]));

     

                 

                  this.pgTemplateInfo.SelectedObjects = myProductList;

     

     

                  DataTable myDataTable = myProductList[0].Table.Clone();

                  myDataTable.Rows.Clear();

     

                  foreach (var row in myProductList)

                  {

                    myDataTable.ImportRow(row );

                  }

                  this.dgvBindProperty.DataSource = myDataTable ;

                }

               

            }

            private void frmWFBrowse_Load(object sender, EventArgs e)

            {

                this.llDeleteTemplate.Enabled = false;

            }

     

            private void llDeleteTemplate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

            {

              

            }

     

         

        }

    }

    3.4 App.config

        <connectionStrings>

            <add name="WinMonoApp.Properties.Settings.BPMDBConnectionString" connectionString="Data Source=10.168.14.131;Initial Catalog=Northwind;User ID=sa;Password=sqlsa" providerName="System.Data.SqlClient"/>

        </connectionStrings>

     

    3.5 运行效果

    3.5.1 PropertyGrid绑定效果

    sql1.jpg

    3.5.2 PropertyGrid子项编辑

    sql2.jpg

    3.5.3 GridView绑定效果

     


     

     

     

     

  • 相关阅读:
    java内存区域
    [POJ] John‘s trip | 欧拉回路 | 边序列字典序最小 + 建图
    [POJ | Nowcoder] Watchcow | 欧拉回路 点路径输出
    [UPC | 山东省赛] The Largest SCC | Tarjan强连通分量瞎搞 + 状态还原
    [Luogu] 炸铁路 | Tarjan 割边
    [HDU 4738] Caocao‘s Bridges | Tarjan 求割边
    [Codeforces 1586] Omkar and Determination | 思维前缀和
    [UVA 1599] Ideal Path | 细节最短路
    [North Central NA Contest 2018] Rational Ratio | 规律 细节模拟
    [HDU 7136] Jumping Monkey | 并查集 | 逆向思维
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/1500789.html
Copyright © 2011-2022 走看看