Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

Could not find installable ISAM.

$
0
0

I am trying to create program in .net using C# for uploading excel file, reading it and add record excel file to the sql server database from excel data. While doing so I have got an error: Could not find installable ISAM?

Can someone help me how to fix this problem?

Or may be provide some sample code to do such kind of assignment in different way?

protected void Button1_Click(object sender, EventArgs e)
String excelConnectionString1; 
String fname = FileUpload1.PostedFile.FileName; 
if (FileUpload1.PostedFile.FileName.EndsWith(".xls")) 
String excelsheet; FileUpload1.SaveAs(Server.MapPath("~/file/" + FileUpload1.FileName));
 if (FileUpload1.PostedFile.FileName.EndsWith(".xls")) 
{
 excelConnectionString1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/file/" + FileUpload1.FileName) + ";Extended Properties=Excel 8.0;HDR=Yes;";
 OleDbConnection myEcelConnection1 = new OleDbConnection(excelConnectionString1);
 myEcelConnection1.Open(); 
if (txtsheet.Text.Length == 0)
 {
 lblmsg.Text = "Please Write File Name"; 
}
 else
excelsheet = "[" + txtsheet.Text + "$" + "]"; 
string sheet = "Select * from [" + txtsheet.Text + "$" + "]"; 
OleDbCommand cmd1 = new OleDbCommand(sheet, myEcelConnection1);
 cmd1.CommandType = CommandType.Text; 
OleDbDataAdapter myAdapter1 = new OleDbDataAdapter(cmd1);
 DataSet myDataSet1 = new DataSet(); myAdapter1.Fill(myDataSet1); 
int a = myDataSet1.Tables[0].Rows.Count - 1; 
string name; 
string dob; 
for (int i = 0; i <= a; i++)
name = myDataSet1.Tables[0].Rows[i].ItemArray[0].ToString();
 dob = myDataSet1.Tables[0].Rows[i].ItemArray[1].ToString();
 SqlConnection con = new SqlConnection("Connection String for Sql Server");
 con.Open(); 
SqlCommand command = new SqlCommand("Insert into info(name,dob)values(@valname,@valdob)", con);
 command.Parameters.Add("@valname", SqlDbType.VarChar, 50).Value = name;
 command.Parameters.Add("@valdob", SqlDbType.VarChar, 50).Value = dob;
 command.CommandType = CommandType.Text;
 SqlDataAdapter da = new SqlDataAdapter(command);
 DataSet ds = new DataSet();
 da.Fill(ds); 
con.Close(); } } } } } }

Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>