Click here to Skip to main content
15,909,896 members
Home / Discussions / C#
   

C#

 
GeneralRe: a href issue Pin
Dave Kreskowiak23-Mar-09 3:50
mveDave Kreskowiak23-Mar-09 3:50 
QuestionHow to get the value of the existing cookie. Pin
Nekkantidivya22-Mar-09 19:42
Nekkantidivya22-Mar-09 19:42 
AnswerRe: How to get the value of the existing cookie. Pin
N a v a n e e t h22-Mar-09 20:01
N a v a n e e t h22-Mar-09 20:01 
Questionhelp on GUI foe Deploy Pin
varun.g22-Mar-09 19:29
varun.g22-Mar-09 19:29 
AnswerRe: help on GUI foe Deploy Pin
N a v a n e e t h22-Mar-09 19:40
N a v a n e e t h22-Mar-09 19:40 
Questionmenu in asp.net Pin
Mangesh Tomar22-Mar-09 19:03
Mangesh Tomar22-Mar-09 19:03 
AnswerRe: menu in asp.net Pin
Christian Graus22-Mar-09 20:39
protectorChristian Graus22-Mar-09 20:39 
Questionrun time exception Pin
Mangesh Tomar22-Mar-09 18:31
Mangesh Tomar22-Mar-09 18:31 
HI here is my code i take 1 txt,1datagride,2 button,1 file dialog box .
on 1 button i open filedialog box select 1 excel file and fetch string in to txt box,and try to open this excel file in datagride view


WHEN I RUN MY PROGRAM A RUN TIME EXCEPTION THROWEN BY OLEDB IE,
Cannot update. Database or object is read-only.
error occures at connection.Open();
my excel file close when program running.
PLZ HELP


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;


namespace filedialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

}

private void button2_Click(object sender, EventArgs e)
{

string filename = @"textBox1.Text";
String connectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + filename + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
//String connectionString="Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+filename +";"+"Extended Properties=Excel 8.0;";
OleDbCommand selectCommand = new OleDbCommand("SELECT * FROM [sheet1$]", connection);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
dataAdapter.SelectCommand = selectCommand;
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);


// double sum = 0.0;
// We'll make some assumptions for brevity of the code.
System.Data.DataTable dataTable = dataSet.Tables[0];
dataGridView1.DataSource = dataSet.Tables[0];
MessageBox.Show(dataGridView1.RowCount.ToString());

connection.Close();
//openFileDialog1.ShowDialog();
//openFileDialog1.ShowDialog();

// return sum;
// directorySearcher1.FindAll();



}

private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog FD = new OpenFileDialog();

FD .Filter="Excel|*.xls";


if (FD.ShowDialog() == DialogResult.OK)
{
textBox1.Text = " " + FD.FileName;
}

}


}



}
AnswerRe: run time exception Pin
Cracked-Down22-Mar-09 18:50
Cracked-Down22-Mar-09 18:50 
GeneralRe: run time exception Pin
Mangesh Tomar22-Mar-09 19:01
Mangesh Tomar22-Mar-09 19:01 
QuestionMMC SnapIn needs to prevent the Console from exiting Pin
Peter Bruderlin22-Mar-09 17:42
Peter Bruderlin22-Mar-09 17:42 
Questionhow to change activesync ipaddress Pin
osemia22-Mar-09 14:56
osemia22-Mar-09 14:56 
QuestionCalling A form by its name which is saved as text in a table . Pin
unitecsoft22-Mar-09 14:31
unitecsoft22-Mar-09 14:31 
AnswerRe: Calling A form by its name which is saved as text in a table . Pin
PIEBALDconsult22-Mar-09 16:27
mvePIEBALDconsult22-Mar-09 16:27 
AnswerRe: Calling A form by its name which is saved as text in a table . Pin
Morven Huang22-Mar-09 20:55
Morven Huang22-Mar-09 20:55 
QuestionSort thru arrays for elements Pin
onetreeup22-Mar-09 13:48
onetreeup22-Mar-09 13:48 
AnswerRe: Sort thru arrays for elements Pin
ABitSmart22-Mar-09 18:14
ABitSmart22-Mar-09 18:14 
AnswerRe: Sort thru arrays for elements [modified] Pin
12Code22-Mar-09 18:17
12Code22-Mar-09 18:17 
QuestionCode for drawing two dimensional "Nautilus" spirals?? Pin
Wej Parry22-Mar-09 12:02
Wej Parry22-Mar-09 12:02 
AnswerRe: Code for drawing two dimensional "Nautilus" spirals?? Pin
Christian Graus22-Mar-09 12:31
protectorChristian Graus22-Mar-09 12:31 
GeneralRe: Code for drawing two dimensional "Nautilus" spirals?? Pin
Wej Parry22-Mar-09 14:13
Wej Parry22-Mar-09 14:13 
QuestionWhere Do I Start Learning About Using SQL Databases in C# Applications? Pin
That Asian Guy22-Mar-09 10:39
That Asian Guy22-Mar-09 10:39 
AnswerRe: Where Do I Start Learning About Using SQL Databases in C# Applications? Pin
Christian Graus22-Mar-09 10:58
protectorChristian Graus22-Mar-09 10:58 
AnswerRe: Where Do I Start Learning About Using SQL Databases in C# Applications? Pin
PIEBALDconsult22-Mar-09 16:31
mvePIEBALDconsult22-Mar-09 16:31 
AnswerRe: Where Do I Start Learning About Using SQL Databases in C# Applications? Pin
Morven Huang22-Mar-09 21:06
Morven Huang22-Mar-09 21:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.