TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
law
NA
2
0
Use Access Table to Set the DataGrid Constrains
Mar 3 2009 12:06 PM
Hi All,
My Aim was to use Access Table structure to limit the Datagrid Structure, However, my code did'nt work in opening the database (Error marked as below):
private System.Windows.Forms.DataGrid dataGridNewOrder;
System.Data.OleDb.OleDbConnection con;
OleDbDataAdapter adapter;
DataSet ds;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private void FrmNewOrder_Load(object sender, System.EventArgs e)
{
//SqlParameter workParam = null;
string query = "Select ProductID, ProductName, Quantity, UnitPrice, Discount, SubtotalPrice, Remarks From OrderDetail";
ConnectToData(query); // establish database connection and create DataSet
dataGridNewOrder.SetDataBinding(ds, "OrderDetail");
DataTable t = ds.Tables["OrderDetail"];
}
public void ConnectToData(string q)
{
ds = new DataSet();
con = new System.Data.OleDb.OleDbConnection(@"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Larry\Documents\Visual Studio Projects\SOMS\bin\Debug\SOMS.mdb");
con.Open(); <<<<<<<<<<<<<<<<<<<<<<<- ERROR
Console.WriteLine("open Con");
adapter = new OleDbDataAdapter(q,con);
adapter.Fill(ds, "OrderDetail");
}
Reply
Answers (
0
)
Stored procedure excuetion error in C#
Error in Disabling the Max, Min and Restore Buttons