Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataset

Status
Not open for further replies.

seiamerica

Technical User
Dec 27, 2005
13
US
I get column name, colValue in a string colName from my dataset.

string colName = (da.Tables["Members"].Columns[j].ColumnName.Trim().ToString() ) ;
string colValue = (da.Tables["Members"].Rows.ItemArray.GetValue(j).ToString() ) ;

I need to update my database by setting colvaues to the specified column names.
cmd1.CommandText="Update Test set "+ colName +" = '"+colValue+"' where ID =" 1);

I get syntax error. Can anyone suggest me where I am doing wrong. Any help is greately appreciated.
 
Correction - My Typo Error. It is table Members and not Test in the Update statement. I still get the error though.
 
Hi,

It seems you are missplacing the last "

From

cmd1.CommandText="Update Test set "+ colName +" = '"+colValue+"' where ID =" 1);

To

cmd1.CommandText="Update Test set "+ colName +" = '"+colValue+"' where ID = 1");

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top