Click here to Skip to main content
15,891,652 members
Home / Discussions / Database
   

Database

 
AnswerRe: SSRS Pin
Eddy Vluggen1-Aug-12 2:48
professionalEddy Vluggen1-Aug-12 2:48 
QuestionReplication Help Pin
Mohamad Shahmardan31-Jul-12 23:09
Mohamad Shahmardan31-Jul-12 23:09 
AnswerRe: Replication Help Pin
Eddy Vluggen1-Aug-12 0:51
professionalEddy Vluggen1-Aug-12 0:51 
GeneralRe: Replication Help Pin
Mohamad Shahmardan1-Aug-12 5:48
Mohamad Shahmardan1-Aug-12 5:48 
GeneralRe: Replication Help Pin
Pete O'Hanlon1-Aug-12 6:03
mvePete O'Hanlon1-Aug-12 6:03 
GeneralRe: Replication Help Pin
Eddy Vluggen1-Aug-12 11:01
professionalEddy Vluggen1-Aug-12 11:01 
AnswerRe: Replication Help Pin
jschell1-Aug-12 6:21
jschell1-Aug-12 6:21 
Questionprogrammatically write changes back to Access 2007 using C# Pin
Ming Luo31-Jul-12 5:42
Ming Luo31-Jul-12 5:42 
Dear all:

I am trying to use C# to communicate a small database build in Access 2007. I can read from the database and I can modify the values and save the changes back to database using the DataGridView. However, I am not sure how to modify the values programmatically.

Here is the code building the connection.
C#
string g_ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\TestDB.accdb";
       
DataSet g_ds= new DataSet();
OleDbConnection g_con = new OleDbConnection(g_ConnectionString);
OleDbDataAdapter  g_adapter = new OleDbDataAdapter("Select * from qrySuggestion", g_con);
g_adapter.Fill(g_ds, "qrySuggestion");

this.dataGridView1.DataSource = g_ds.Tables[0];
g_con.Close();


I have a button on the form and when the button is clicked, save the changes back to the database. The code is as follows:
C#
public void SaveTable(string tblName, DataTable tbl)
 {
     g_adapter = new OleDbDataAdapter("select * from " + tblName, g_con);

     OleDbCommandBuilder bu = new OleDbCommandBuilder(g_adapter);

     g_adapter.UpdateCommand = bu.GetUpdateCommand();
     g_adapter.Update(tbl);

     tbl.AcceptChanges();

     g_con.Close();
 }

I can use the above code to read from the database and display the data in the DataGridView with no problem. And I can make modification in the DataGridView and save it back by calling the SaveTable method.

However, the problem is that I want to make modification programmatically and reflect the changes back to the database. What I did was to add two statement at the beginning of the SaveTable method as:
C#
DataRow row = tbl.Rows[0];
row[0] = 30;

assuming the column 0 i.e. row[0] is a int field.

When I add those two statement at the beginning of the SaveTable method. An exception will occur at g_adapter.Update(tbl); the exception is something like:
C#
Missing DataColumn"pk_ID" in SourceColumn "pk_ID" in DataTable "tblSuggestionBase"


Can anyone help me out with the problem please?

Thanks
Asura

Questionsplit string in MySQL Pin
Jassim Rahma31-Jul-12 3:23
Jassim Rahma31-Jul-12 3:23 
AnswerRe: split string in MySQL Pin
Blue_Boy31-Jul-12 5:14
Blue_Boy31-Jul-12 5:14 
GeneralRe: split string in MySQL Pin
Jassim Rahma31-Jul-12 11:14
Jassim Rahma31-Jul-12 11:14 
QuestionProblem with MySQL Full-Text Search Pin
Jassim Rahma29-Jul-12 10:49
Jassim Rahma29-Jul-12 10:49 
AnswerRe: Problem with MySQL Full-Text Search Pin
Bernhard Hiller29-Jul-12 22:15
Bernhard Hiller29-Jul-12 22:15 
GeneralRe: Problem with MySQL Full-Text Search Pin
Jassim Rahma31-Jul-12 11:18
Jassim Rahma31-Jul-12 11:18 
QuestionVisual C# not showing up in my project type choices Pin
SQL Ed29-Jul-12 0:14
SQL Ed29-Jul-12 0:14 
Questionhelp with MySQL dynamic sql Pin
Jassim Rahma28-Jul-12 11:06
Jassim Rahma28-Jul-12 11:06 
AnswerRe: help with MySQL dynamic sql Pin
Mycroft Holmes28-Jul-12 13:59
professionalMycroft Holmes28-Jul-12 13:59 
AnswerRe: help with MySQL dynamic sql Pin
Richard MacCutchan28-Jul-12 21:20
mveRichard MacCutchan28-Jul-12 21:20 
GeneralRe: help with MySQL dynamic sql Pin
Jassim Rahma29-Jul-12 8:37
Jassim Rahma29-Jul-12 8:37 
GeneralRe: help with MySQL dynamic sql Pin
Richard MacCutchan29-Jul-12 9:10
mveRichard MacCutchan29-Jul-12 9:10 
AnswerRe: help with MySQL dynamic sql Pin
Eddy Vluggen29-Jul-12 9:41
professionalEddy Vluggen29-Jul-12 9:41 
Questionwcf Pin
PraveenSura27-Jul-12 18:36
PraveenSura27-Jul-12 18:36 
GeneralRe: wcf Pin
jschell28-Jul-12 6:44
jschell28-Jul-12 6:44 
AnswerRe: wcf Pin
Wes Aday28-Jul-12 9:11
professionalWes Aday28-Jul-12 9:11 
QuestionSQL - Finding same product in different waehouse where price is not the same Pin
Richard.Berry10026-Jul-12 1:24
Richard.Berry10026-Jul-12 1:24 

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.