本文介绍了如何在ASP.NET中将mdb中的数据插入远程系统上的mdb(使用静态ip)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从mdb将数据插入mdb。它在我的本地(LAN区域)上正常工作但问题是我在远程系统上插入数据(使用静态IP)文件无法访问(不存在)。 />
我的代码如下。



我的尝试:



I want to insert data into mdb from mdb.It is work properly on my local(LAN area) but problem is when i insert data on my remote system(using static ip) file not access(not exist).
My code below.

What I have tried:

DataTable schemaTable;
        OleDbConnection connn = new OleDbConnection();
        OleDbCommand cmdD = new OleDbCommand();
        connn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
               @"Data source=D:\TDATA\att2000.mdb";
        connn.Open();
        cmdD.Connection = connn;
        //data source=\\static ip\D:\db\att2000.mdb;Persist Security Info=False"
        string templetDataTable = @"\\static ip here\D:\db\att2000.mdb;Persist Security Info=False";
        string clientDataTable = @"D:\TDATA\att2000.mdb";
        string templetBackupDataTable = @"D:\TDATA\att2000.mdb";
        if (File.Exists(templetDataTable))
        {   //**********MDB Data Migration**************//
            schemaTable = connn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
                         new Object[] { null, null, null, "TABLE" });
            //1. Copy Existing Data from  Clientfolder to the New Templet
            for (int i = 0; i < 1; i++)
            {
                string query = "INSERT INTO " + schemaTable.Rows[29].ItemArray[2].ToString() + " IN '" + templetDataTable + "' SELECT * FROM " + schemaTable.Rows[4].ItemArray[2].ToString() +"";
                cmdD.CommandType = CommandType.Text;
                cmdD.CommandText = query;
                try
                {
                    cmdD.ExecuteNonQuery();
                    this.RegisterStartupScript("clientScript", ObjERP.strScr1 + "DATA MODIFY SUCESSFULLY" + ObjERP.strScr2);

                }
                catch (Exception ex)
                {
                    //txtErrorDetails.Visible = true;
                    //txtErrorDetails.Text = ex.ToString();
                    //errorLogger = new StreamWriter(@"ErrorLog" + DateTime.Now.ToString("ddMMyyyyMMhhss") + ".Log");
                    //errorLogger.WriteLine(txtErrorDetails.Text + " \n Error While Updating Table.."
                    //                       + schemaTable.Rows[i].ItemArray[2].ToString() + "{" + ex.ToString() + "}");
                    //errorLogger.Flush();
                    //continue;
                }
            }

            connn.Close();
            try
            {
                //2. Move Client MDB to seperate folder
                File.Move(clientDataTable, templetBackupDataTable);
                //3. Move Updated templet MDB to Client application data folder
                File.Move(templetDataTable, clientDataTable);
                //4. Delete old Client MDB 
                 File.Delete(templetBackupDataTable);
            }
            catch (Exception ex)
            {
            }
        }

推荐答案

string templetDataTable = @"\\static ip here\D:\db\att2000.mdb;Persist Security Info=False";



应该读取


should probably read

string templetDataTable = @"\\static ip here\db\att2000.mdb;Persist Security Info=False";

即删除 D:\ 或将其替换为共享名称

I.e. remove the D:\ or replace it with the name of the Share


这篇关于如何在ASP.NET中将mdb中的数据插入远程系统上的mdb(使用静态ip)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 18:59