找不到可安装的isam(错误) [英] Could not find installable isam (error)

查看:100
本文介绍了找不到可安装的isam(错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

namespace Excel_to_Access
{
    public partial class Defult : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int rollno;
            String sname;
            String fname;
            String sclass;
            string path = Path.GetFileName(FileUpload1.FileName);
            path = path.Replace(" ", "");
            FileUpload1.SaveAs(Server.MapPath("~/ExcelFile/") + path);
            String ExcelPath = Server.MapPath("~/ExcelFile/") + path;

            string mycon = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelPath + ";Extend Properties=Excel 8.0;Persist Security Info = False";
            OleDbConnection conn = new OleDbConnection(mycon);
            conn.Open(); 
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", conn);
            OleDbDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
//Response.Write("<br>"+dr[0].ToString());
                rollno = Convert.ToInt32(dr[0].ToString());
                sname = dr[1].ToString();
                fname = dr[2].ToString();
                sclass = dr[3].ToString();
                savedata(rollno, sname, fname, sclass);
 }

            Label1.Text = "Data Has Been Saved Successfully";
        }

        private void savedata(int rollno1, String sname1, String fname1, String sclass1)
        {
            OleDbConnection con;
            OleDbCommand com;
            con = new OleDbConnection("Provider= Microsoft.Jet.OLEDB.4.0;Data Source" + Server.MapPath("~/App_Data/StudentData.accdb") + ";Persist Security Info=False");
            con.Open();
            String data1;
            data1 = "insert into studentdetails values(" + rollno1 + ",'" + sname1 + "','" + fname1 + "','" + sclass1 + "')";
            com = new OleDbCommand(data1, con);
            com.ExecuteNonQuery();
            con.Close();
            Label1.Text = "Data Has Been Upload to MS Access Database Successfully";
        }
    }
}

What I have tried:

<pre>string mycon = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelPath + ";Extend Properties=Excel 8.0;Persist Security Info = False";
            OleDbConnection conn = new OleDbConnection(mycon);
            conn.Open();

推荐答案

,conn);
OleDbDataReader dr = cmd.ExecuteReader( );
while(dr.Read())
{
//Response.Write(< br>+ dr [0] .ToString());
rollno = Convert.ToInt32(dr [0] .ToString());
sname = dr [1] .ToString();
fname = dr [2] .ToString();
sclass = dr [3] .ToString();
savedata(rollno,sname,fname,sclass);
}

Label1.Text =数据已成功保存 ;
}

private void savedata(int rollno1,String sname1,String fname1,String sclass1)
{
OleDbConnection con;
OleDbCommand com;
con = new OleDbConnection(Provider = Microsoft.Jet.OLEDB.4.0; Data Source+ Server.MapPath(〜/ App_Data / StudentData.accdb)+; Persist Security Info = False);
con.Open();
String data1;
data1 =插入studentdetails值(+ rollno1 +,+ sname1 +','+ fname1 +','+ sclass1 +');
com = new OleDbCommand(data1,con);
com.ExecuteNonQuery();
con.Close();
Label1.Text =数据已成功上传到MS Access数据库;
}
}
}

我尝试了什么:

< pre> string mycon = Provider = Microsoft.Jet.OLEDB.4.0; Data Source =+ ExcelPath +; Extend Properties = Excel 8.0; Persist Security Info = False;
OleDbConnection conn = new OleDbConnection(mycon);
conn.Open();
", conn); OleDbDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { //Response.Write("<br>"+dr[0].ToString()); rollno = Convert.ToInt32(dr[0].ToString()); sname = dr[1].ToString(); fname = dr[2].ToString(); sclass = dr[3].ToString(); savedata(rollno, sname, fname, sclass); } Label1.Text = "Data Has Been Saved Successfully"; } private void savedata(int rollno1, String sname1, String fname1, String sclass1) { OleDbConnection con; OleDbCommand com; con = new OleDbConnection("Provider= Microsoft.Jet.OLEDB.4.0;Data Source" + Server.MapPath("~/App_Data/StudentData.accdb") + ";Persist Security Info=False"); con.Open(); String data1; data1 = "insert into studentdetails values(" + rollno1 + ",'" + sname1 + "','" + fname1 + "','" + sclass1 + "')"; com = new OleDbCommand(data1, con); com.ExecuteNonQuery(); con.Close(); Label1.Text = "Data Has Been Upload to MS Access Database Successfully"; } } } What I have tried: <pre>string mycon = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelPath + ";Extend Properties=Excel 8.0;Persist Security Info = False"; OleDbConnection conn = new OleDbConnection(mycon); conn.Open();


正常的原因是你试图使用64位应用程序:Jet引擎永远不会以64位版本发行,所以你根本无法从64位应用程序访问Jet。



最好的解决方案是切换到ACE - 它来自32和64位版本 - 但如果必须使用Jet,也可以将应用程序更改为32位。请记住,您需要使用应用程序引用的每个DLL程序集的32位版本,否则它们也将无法运行。因此升级到Ace ...
The normal reason for this is that you are trying to use a 64 bit application: the Jet engine was never issued in a 64 bit version, so you cannot access Jet from a 64 bit app at all.

The best solution is to switch to ACE instead - it comes in 32 and 64 bit versions - but it's also possible to change you app to 32 bit if you must use Jet. Do bear in mind that you will need to use 32 bit versions of every DLL assembly your app references as well or they won't work either. Hence upgrading to Ace instead...


data1 = "insert into studentdetails values(" + rollno1 + ",'" + sname1 + "','" + fname1 + "','" + sclass1 + "')";



不是你问题的解决方案,而是你遇到的另一个问题。

永远不要通过连接来构建SQL查询字符串。迟早,您将使用用户输入来执行此操作,这会打开一个名为SQL注入的漏洞,这对您的数据库很容易并且容易出错。

名称中的单引号你的程序崩溃。如果用户输入像Brian O'Conner这样的名称可能会使您的应用程序崩溃,那么这是一个SQL注入漏洞,崩溃是最少的问题,恶意用户输入,并且它被提升为具有所有凭据的SQL命令。

SQL注入 - 维基百科 [ ^ ]

SQL注入 [ ^ ]

按示例进行SQL注入攻击 [ ^ ]

PHP:SQL注入 - 手册 [ ^ ]

SQL注入预防备忘单 - OWASP [ ^ ]

我该怎么办?解释没有技术术语的SQL注入? - 信息安全堆栈交换 [ ^ ]


Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[^]


这篇关于找不到可安装的isam(错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆