Click here to Skip to main content
15,892,697 members
Home / Discussions / Database
   

Database

 
GeneralRe: My Ox is Flummed! Pin
jschell22-Jun-11 9:15
jschell22-Jun-11 9:15 
GeneralRe: My Ox is Flummed! Pin
TheComputerMan22-Jun-11 9:23
TheComputerMan22-Jun-11 9:23 
GeneralRe: My Ox is Flummed! Pin
jschell22-Jun-11 9:29
jschell22-Jun-11 9:29 
QuestionTrying to get the output of this code down to 1 line vs 1886 it currently displays. Can anyone help? Pin
SQL Ed20-Jun-11 9:49
SQL Ed20-Jun-11 9:49 
AnswerRe: Trying to get the output of this code down to 1 line vs 1886 it currently displays. Can anyone help? Pin
Tim Carmichael20-Jun-11 10:25
Tim Carmichael20-Jun-11 10:25 
QuestionRe: Trying to get the output of this code down to 1 line vs 1886 it currently displays. Can anyone help? Pin
SQL Ed21-Jun-11 6:24
SQL Ed21-Jun-11 6:24 
AnswerRe: Trying to get the output of this code down to 1 line vs 1886 it currently displays. Can anyone help? [modified] Pin
TrustTheMath21-Jun-11 9:00
TrustTheMath21-Jun-11 9:00 
QuestionSQL Update Statement, OleDbDataAdapter, and ms access 2007 Pin
VonHagNDaz17-Jun-11 8:05
VonHagNDaz17-Jun-11 8:05 
Hi guys,

I'm trying to understand an Update query generated from vs2010. I'm new to sql and all of the msdn answers are hard-coded, and I need some help to do this with variable data.

I've figured out my insert statement

DataSet dataChanges = new UserData();
                dataChanges.DataSetName = "dataChanges";

                dataChanges = this._userDataSet.GetChanges(DataRowState.Modified | DataRowState.Added | DataRowState.Deleted);

                this._dbConnection.ConnectionString = this._connectionString;
                this._dbConnection.Open();

                //insert new rows
                OleDbCommand command = new OleDbCommand("INSERT INTO tblUsers(ID_NAME, ID_PASSWORD, ID_RIGHTS, ID_JOBS)VALUES(?, ?, ?, ?)", this._dbConnection);
                command.Parameters.Add(this._userDataSet.tblUsers.ID_NAMEColumn.ColumnName,
                                        OleDbType.VarChar,
                                        this._userDataSet.tblUsers.ID_NAMEColumn.MaxLength, 
                                        "ID_NAME");

                command.Parameters.Add(this._userDataSet.tblUsers.ID_PASSWORDColumn.ColumnName,
                                        OleDbType.VarChar,
                                        this._userDataSet.tblUsers.ID_PASSWORDColumn.MaxLength,
                                        "ID_PASSWORD");

                command.Parameters.Add(this._userDataSet.tblUsers.ID_RIGHTSColumn.ColumnName,
                                        OleDbType.Integer,
                                        this._userDataSet.tblUsers.ID_RIGHTSColumn.MaxLength, 
                                        "ID_RIGHTS");

                command.Parameters.Add(this._userDataSet.tblUsers.ID_JOBSColumn.ColumnName,
                                        OleDbType.Integer,
                                        this._userDataSet.tblUsers.ID_JOBSColumn.MaxLength,
                                        "ID_JOBS");
                this._dbAdapter.InsertCommand = command;


_userDataSet is a typed dataset.
The vs generated UPDATE query looks like this:
//update rows;
                command = new OleDbCommand("UPDATE tblUsers SET ID_NAME = ?, ID_PASSWORD = ?," +
                                            "ID_RIGHTS = ?, ID_JOBS = ? WHERE ((ID_NAME = ?) AND" + 
                                            "((? = 1 AND ID_PASSWORD IS NULL) OR (ID_PASSWORD = ?))" +
                                            "AND ((? = 1 AND ID_RIGHTS IS NULL) OR (ID_RIGHTS = ?))" +
                                            "AND ((? = 1 AND ID_JOBS IS NULL) OR (ID_JOBS = ?)))", this._dbConnection);


All the msdn examples are hard coded, ...SET ID_NAME = "some static text string"...

1) I know the "?" are placeholders for the parameters, but which values go where?
2) After I build my Add, Update, and Delete commands, I call
this._dbAdapter.Update(dataChanges, "tblUsers");

which should execute all three commands based on the changes to the dataset, so I'd like to know how to do this programatically.

Kind of a big question, but I've been banging my head on the wall for the better part of a day.
[Insert Witty Sig Here]

AnswerRe: SQL Update Statement, OleDbDataAdapter, and ms access 2007 Pin
Matt U.19-Jun-11 6:40
Matt U.19-Jun-11 6:40 
QuestionKeep history table [modified] Pin
Rahul.RK14-Jun-11 20:05
Rahul.RK14-Jun-11 20:05 
AnswerRe: Keep history table Pin
_Damian S_14-Jun-11 20:32
professional_Damian S_14-Jun-11 20:32 
AnswerRe: Keep history table Pin
FeatherstoneBC15-Jun-11 7:37
FeatherstoneBC15-Jun-11 7:37 
AnswerRe: Keep history table Pin
jschell15-Jun-11 9:08
jschell15-Jun-11 9:08 
AnswerArchive Pin
David Mujica16-Jun-11 2:54
David Mujica16-Jun-11 2:54 
AnswerRe: Keep history table Pin
Simon_Whale16-Jun-11 6:28
Simon_Whale16-Jun-11 6:28 
QuestionHow to get reference information between parent and child tables (MS SQL Server/MSAccess)? [modified] Pin
priyamtheone13-Jun-11 19:51
priyamtheone13-Jun-11 19:51 
AnswerRe: How to get reference information between parent and child tables (MS SQL Server/MSAccess)? Pin
_Damian S_13-Jun-11 20:09
professional_Damian S_13-Jun-11 20:09 
GeneralRe: How to get reference information between parent and child tables (MS SQL Server/MSAccess)? Pin
priyamtheone13-Jun-11 21:12
priyamtheone13-Jun-11 21:12 
AnswerRe: How to get reference information between parent and child tables (MS SQL Server/MSAccess)? Pin
Simon_Whale13-Jun-11 22:42
Simon_Whale13-Jun-11 22:42 
AnswerRe: How to get reference information between parent and child tables (MS SQL Server/MSAccess)? Pin
Mycroft Holmes14-Jun-11 1:20
professionalMycroft Holmes14-Jun-11 1:20 
QuestionSelect records from a single table that have common data in two columns Pin
Frank Lepkowski13-Jun-11 10:43
Frank Lepkowski13-Jun-11 10:43 
AnswerRe: Select records from a single table that have common data in two columns Pin
GenJerDan13-Jun-11 11:11
GenJerDan13-Jun-11 11:11 
AnswerRe: Select records from a single table that have common data in two columns Pin
Johan Hakkesteegt13-Jun-11 22:40
Johan Hakkesteegt13-Jun-11 22:40 
GeneralRe: Select records from a single table that have common data in two columns Pin
_Damian S_14-Jun-11 14:54
professional_Damian S_14-Jun-11 14:54 
GeneralRe: Select records from a single table that have common data in two columns Pin
Johan Hakkesteegt14-Jun-11 21:26
Johan Hakkesteegt14-Jun-11 21:26 

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.