简单的链接数据库

本文介绍了一种从数据库中批量读取特定记录,并利用这些记录中的数据进行坐标转换及后续插入到另一个数据库的方法。该过程涉及使用 C# 进行数据库操作、坐标点解析以及异步处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

            HzBLib.IDAL.ISBiz sBiz = HzBLib.DAL.Factory.CreateSBiz();
            HzBLib.Model.Collection<HzBLib.Model.SBiz> sList = sBiz.Select("select * from s_biz");
            string strconn = "server=192.168.8.101;uid=sa;pwd=sa;database=HzBus20090714;Asynchronous Processing=true";
            if (sList.Count > 0)
            {
                for (int i = 0; i < sList.Count; i++)
                {
                    double _x = 0;
                    double _y = 0;
                    string strname = sList[i].FName;
                    string strmark = sList[i].FExternalMark;
                    string strcatalog = sList[i].FCatalog;
                    SGis.SGeometry.SPoint xPoint =  SGis.SGeometry.SPoint.FromStringBySpace(HzBLib.Common.ConvertByteArrayToString(sList[i].FShapeRoad));
                    SGis.SGeometry.SPoint xPoint1 =  SGis.SGeometry.SPoint.FromStringBySpace(HzBLib.Common.ConvertByteArrayToString(sList[i].FShapeGps));
                    if (xPoint != null)
                    {
                        _x = xPoint.X;
                        _y = xPoint.Y;
                    }
                    else if (xPoint1 != null)
                    {
                        _x = xPoint1.X;
                        _y = xPoint1.Y;
                    }
                    else
                    {
                        _x = 0;
                        _y = 0;
                    }

                    SqlConnection conn = new SqlConnection(strconn);
                    string strsql = "insert into Copy_sbiz values('"+strname+"','"+strmark+"','"+_x+"','"+_y+"','"+ strcatalog +"')";
                    //SqlDataAdapter da = new SqlDataAdapter(strsql, conn);
                    //DataSet ds = new DataSet();
                    //da.Fill(ds);
                    conn.Open();
                    SqlCommand comm = new SqlCommand(strsql, conn);
                    IAsyncResult a = comm.BeginExecuteNonQuery();
                    comm.EndExecuteNonQuery(a);
                    conn.Close();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值