Click here to Skip to main content
15,902,114 members
Home / Discussions / Database
   

Database

 
GeneralRe: Select count and select Pin
Colin Angus Mackay19-Apr-07 1:46
Colin Angus Mackay19-Apr-07 1:46 
GeneralRe: Select count and select Pin
N a v a n e e t h19-Apr-07 2:58
N a v a n e e t h19-Apr-07 2:58 
Questiondata moving Pin
tradakad18-Apr-07 22:16
tradakad18-Apr-07 22:16 
AnswerRe: data moving Pin
Colin Angus Mackay18-Apr-07 22:25
Colin Angus Mackay18-Apr-07 22:25 
GeneralRe: data moving Pin
tradakad18-Apr-07 22:47
tradakad18-Apr-07 22:47 
GeneralRe: data moving Pin
Mike Dimmick19-Apr-07 3:17
Mike Dimmick19-Apr-07 3:17 
GeneralRe: data moving Pin
Colin Angus Mackay19-Apr-07 3:25
Colin Angus Mackay19-Apr-07 3:25 
Questionupdate statement syntax error Pin
rkherath18-Apr-07 21:45
rkherath18-Apr-07 21:45 
HI all,

my application is to read a access dtbase tables which has the same format of columns. but it gives an update statement Syntax error. please help


OleDbConnection con = new OleDbConnection();
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand selcom = new OleDbCommand();
OleDbCommand upcom = new OleDbCommand();
DataSet ds = new DataSet();


private void button1_Click(object sender, EventArgs e)
{
string path = txtSelectLoc.Text;
processTables(path);
//UpdateMethod(path, "GRO");





}


void processTables(string path)
{

DataTable dt = new DataTable();
dt = sqlConnection().Tables[0];

foreach (DataRow dr in dt.Rows)
{

UpdateMethod(path,"WWA");

}




}


DataSet sqlConnection()
{
SqlCommand sqlSelect = new SqlCommand();
SqlConnection SQLcon = new SqlConnection("data source=Ruwandi;initial catalog=MIS;user id=sa");
SqlDataAdapter SQLda = new SqlDataAdapter();
sqlSelect.CommandText= "Select Alias from mfLocation where Alias<>''";
sqlSelect.Connection=SQLcon;
SQLda.SelectCommand = sqlSelect;
SQLda.Fill(ds);
return ds;
//dataGridView1.DataSource = ds.Tables[0];
}

private void UpdateMethod(string path,string tbName)
{
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path +
";Jet OLEDB:Database Password=sanuja";
DataTable dt = SelectMethod(tbName).Tables[0];
upcom.Connection = con;
con.Open();
int x = 0;
foreach (DataRow dr in dt.Rows)
{

x = x + 1;
string str = dr["CATEGORY"].ToString();
dr.AcceptChanges();
upcom.CommandText = "update CON_"+ tbName +" set BGT_APR=0,BGT_MAY=0,BGT_JUN=0,BGT_JUL=0,BGT_AUG=0,BGT_SEP=0,BGT_OCT=0,BGT_NOV=0,BGT_DEC=0,BGT_JAN=0,BGT_FEB=0,BGT_MAR=0,BUDGETED=0,BUDGET_PES=0," +
"NET_APR=0,NET_MAY=0,NET_JUN=0,NET_JUL=0,NET_AUG=0,NET_SEP=0,NET_OCT=0,NET_NOV=0,NET_DEC=0,NET_JAN=0,NET_FEB=0,NET_MAR=0," +
"LYNET_APR=" + dr["NET_APR"] + ",LYNET_MAY=" + dr["NET_MAY"] + ",LYNET_JUN=" + dr["NET_JUN"] + ",LYNET_JUL=" + dr["NET_JUL"] + ",LYNET_AUG=" + dr["NET_AUG"] + ",LYNET_SEP=" + dr["NET_SEP"] + ",LYNET_OCT=" + dr["NET_OCT"] + ",LYNET_NOV=" + dr["NET_NOV"] + ",LYNET_DEC=" + dr["NET_DEC"] + ",LYNET_JAN=" + dr["NET_JAN"] + ",LYNET_FEB=" + dr["NET_FEB"] + ",LYNET_MAR=" + dr["NET_MAR"] + "," +
"ADJ_APR=0,ADJ_MAY=0,ADJ_JUN=0,ADJ_JUL=0,ADJ_AUG=0,ADJ_SEP=0,ADJ_OCT=0,ADJ_NOV=0,ADJ_DEC=0,ADJ_JAN=0,ADJ_FEB=0,ADJ_MAR=0," +
"LYADJ_APR=" + dr["ADJ_APR"] + ",LYADJ_MAY=" + dr["ADJ_MAY"] + ",LYADJ_JUN=" + dr["ADJ_JUN"] + ",LYADJ_JUL=" + dr["ADJ_JUL"] + ",LYADJ_AUG=" + dr["ADJ_AUG"] + ",LYADJ_SEP=" + dr["ADJ_SEP"] + ",LYADJ_OCT=" + dr["ADJ_OCT"] + ",LYADJ_NOV=" + dr["ADJ_NOV"] + ",LYADJ_DEC=" + dr["ADJ_DEC"] + ",LYADJ_JAN=" + dr["ADJ_JAN"] + ",LYADJ_FEB=" + dr["ADJ_FEB"] + ",LYADJ_MAR=" + dr["ADJ_MAR"] +
" where CATEGORY=\'" + str + "\'";

da.UpdateCommand = upcom;
upcom.ExecuteNonQuery();

}
dt.AcceptChanges();

dataGridView1.DataSource = dt;
}

DataSet SelectMethod(string tbName)
{
selcom.CommandText = "select * from CON_"+tbName;
selcom.Connection = con;
da.SelectCommand = selcom;
da.Fill(ds);
return ds;

}

private void butSelectLoc_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog();

if (result == DialogResult.OK)
{
string path = openFileDialog1.FileName;
txtSelectLoc.Text = path;
}
}


regards
ruwandi

rkherath
AnswerRe: update statement syntax error Pin
Colin Angus Mackay18-Apr-07 22:24
Colin Angus Mackay18-Apr-07 22:24 
GeneralRe: update statement syntax error Pin
rkherath18-Apr-07 22:46
rkherath18-Apr-07 22:46 
Questionshow tables Pin
tradakad18-Apr-07 20:35
tradakad18-Apr-07 20:35 
AnswerRe: show tables Pin
gauthee18-Apr-07 20:55
gauthee18-Apr-07 20:55 
GeneralRe: show tables Pin
tradakad18-Apr-07 21:46
tradakad18-Apr-07 21:46 
GeneralRe: show tables Pin
gauthee18-Apr-07 22:47
gauthee18-Apr-07 22:47 
Question2-way Merge Replication(PDASql Server 2000) Pin
ayyappa4902118-Apr-07 19:41
ayyappa4902118-Apr-07 19:41 
Questionfind exact Hour and minutes..... Pin
Member 387988118-Apr-07 19:05
Member 387988118-Apr-07 19:05 
AnswerRe: find exact Hour and minutes..... Pin
Krish - KP18-Apr-07 19:28
Krish - KP18-Apr-07 19:28 
GeneralRe: find exact Hour and minutes..... Pin
Member 387988118-Apr-07 19:40
Member 387988118-Apr-07 19:40 
GeneralRe: find exact Hour and minutes..... Pin
Krish - KP18-Apr-07 20:13
Krish - KP18-Apr-07 20:13 
Questionwhen updating value repeats for all the the Columns Pin
rkherath18-Apr-07 18:03
rkherath18-Apr-07 18:03 
QuestionUpdate tables Pin
hahii18-Apr-07 12:25
hahii18-Apr-07 12:25 
AnswerRe: Update tables Pin
Colin Angus Mackay18-Apr-07 14:21
Colin Angus Mackay18-Apr-07 14:21 
AnswerRe: Update tables Pin
DQNOK19-Apr-07 3:38
professionalDQNOK19-Apr-07 3:38 
QuestionSql Server triggers Pin
AKSSMV18-Apr-07 12:17
AKSSMV18-Apr-07 12:17 
AnswerRe: Sql Server triggers Pin
Colin Angus Mackay18-Apr-07 14:24
Colin Angus Mackay18-Apr-07 14: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.