|
-
Feb 28th, 2007, 09:32 AM
#1
Thread Starter
Hyperactive Member
What is wrong with this code
using System;
using System.Data;
using System.Data.OleDb;
namespace practice
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
OleDbConnection sqlcn=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;data source =Path of Database");
sqlcn.Open();
OleDbDataAdapter sqlda=new OleDbDataAdapter("SELECT Name FROM TABLE1",sqlcn);
OleDbCommandBuilder cmdbl=new OleDbCommandBuilder(sqlda);
DataSet ds=new DataSet();
sqlda.Fill(ds,"Table1");
Console.WriteLine(ds.Tables["Table1"].Rows[0]["Name"]);
ds.Tables["Table1"].Rows[0]["Name"]="Haider";
sqlda.Update(ds,"Table1");
Console.WriteLine(ds.Tables["Table1"].Rows[0]["name"]);
sqlcn.Close();
Console.ReadLine();
}
}
}
I got exception that Update is not possible since of a query. The exception is thrown at line sqlda.Update(ds,"Table1")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|