|
Oh god sorry man really its working cool...,
once again sorry man..........,
Thank u frd
Magi
|
|
|
|
|
|
hi,
I am having a Access table which does not have a primary key.
i wanna change data in all the rows. my coding has no errors . but when i try to update it writes the same value for all the rows per field. please help me i am stuck with this.
here is the coding
void oledbConnection(/*string path, string CONstr*/)
{
//OleDbTransaction trans;
OleDbCommand OLEDBSelectCom = new OleDbCommand();
OleDbCommand OLEDBupdateCom = new OleDbCommand();
OleDbCommand OLEDBDeletecom = new OleDbCommand();
OleDbCommand OLEDBInsertCom = new OleDbCommand();
OleDbConnection OLEDBcon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\yearEndExe\\WmsFoodCityPerformance" +
".mdb;Jet OLEDB:Database Password=sanuja");
OLEDBcon.Open();
OleDbTransaction trans;
trans = OLEDBcon.BeginTransaction();
OleDbDataAdapter OLEDBda = new OleDbDataAdapter();
OLEDBSelectCom.Transaction = trans;
OLEDBSelectCom.UpdatedRowSource = UpdateRowSource.Both;
OLEDBSelectCom.CommandText = "Select * from CON_MIN";
//OLEDBDeletecom.CommandText = "Delete from CON_KPT";
OLEDBupdateCom.Connection = OLEDBcon;
OLEDBSelectCom.Connection = OLEDBcon;
DataSet ds = new DataSet();
OLEDBda.SelectCommand = OLEDBSelectCom;
OLEDBda.UpdateCommand = OLEDBupdateCom;
OleDbCommandBuilder combil = new OleDbCommandBuilder(OLEDBda);
OLEDBda.Fill(ds);
DataTable dt = new DataTable();
dt = ds.Tables[0];
int x=0;
dataGridView1.DataSource = dt;
MessageBox.Show("Select completed");
foreach (DataRow dr in dt.Rows)
{
//MessageBox.Show(dr["NET_JUL"].ToString());
//MessageBox.Show(dr["LYNET_JUL"].ToString());
dr.BeginEdit();
dr["BGT_APR"] = 0;
dr["BGT_JUN"] = 0;
dr["BGT_JUL"] = 0;
dr["BGT_AUG"] = 0;
dr["BGT_SEP"] = 0;
dr["BGT_OCT"] = 0;
dr["BGT_NOV"] = 0;
dr["BGT_DEC"] = 0;
dr["BGT_JAN"] = 0;
dr["BGT_FEB"] = 0;
dr["BGT_MAR"] = 0;
dr["BUDGETED"] = 0;
dr["BUDGET_PES"] = 0;
dr["LYNET_APR"] = dr["NET_APR"];
dr["LYNET_JUN"] = dr["NET_JUN"];
dr["LYNET_JUL"] = dr["NET_JUL"];
dr["LYNET_AUG"] = dr["NET_AUG"];
dr["LYNET_SEP"] = dr["NET_SEP"];
dr["LYNET_OCT"] = dr["NET_OCT"];
dr["LYNET_NOV"] = dr["NET_NOV"];
dr["LYNET_DEC"] = dr["NET_DEC"];
dr["LYNET_JAN"] = dr["NET_JAN"];
dr["LYNET_FEB"] = dr["NET_FEB"];
dr["LYNET_MAR"] = dr["NET_MAR"];
dr["NET_APR"] = 0;
dr["NET_JUN"] = 0;
dr["NET_JUL"] = 0;
dr["NET_AUG"] = 0;
dr["NET_SEP"] = 0;
dr["NET_OCT"] = 0;
dr["NET_NOV"] = 0;
dr["NET_DEC"] = 0;
dr["NET_JAN"] = 0;
dr["NET_FEB"] = 0;
dr["NET_MAR"] = 0;
dr["LYADJ_APR"] = dr["ADJ_APR"];
dr["LYADJ_JUN"] = dr["ADJ_JUN"];
dr["LYADJ_JUL"] = dr["ADJ_JUL"];
dr["LYADJ_AUG"] = dr["ADJ_AUG"];
dr["LYADJ_SEP"] = dr["ADJ_SEP"];
dr["LYADJ_OCT"] = dr["ADJ_OCT"];
dr["LYADJ_NOV"] = dr["ADJ_NOV"];
dr["LYADJ_DEC"] = dr["ADJ_DEC"];
dr["LYADJ_JAN"] = dr["ADJ_JAN"];
dr["LYADJ_FEB"] = dr["ADJ_FEB"];
dr["LYADJ_MAR"] = dr["ADJ_MAR"];
dr["LYADJ_APR"] = 0;
dr["LYADJ_JUN"] = 0;
dr["LYADJ_JUL"] = 0;
dr["LYADJ_AUG"] = 0;
dr["LYADJ_SEP"] = 0;
dr["LYADJ_OCT"] = 0;
dr["LYADJ_NOV"] = 0;
dr["LYADJ_DEC"] = 0;
dr["LYADJ_JAN"] = 0;
dr["LYADJ_FEB"] = 0;
dr["LYADJ_MAR"] = 0;
dr.EndEdit();
//MessageBox.Show(dr["NET_JUL"].ToString());
//MessageBox.Show(dr["LYNET_JUL"].ToString());
OLEDBupdateCom.CommandText = "Update CON_MIN set NET_APR=0,LYNET_APR=@LYNET_APR,NET_MAY=0,LYNET_MAY=@LYNET_MAY,NET_JUN=0,LYNET_JUN=@LYNET_JUN,NET_JUL=0,LYNET_JUL=@LYNET_JUL,NET_AUG=0,LYNET_AUG=@LYNET_AUG,NET_SEP=0,LYNET_SEP=@LYNET_SEP,NET_OCT=0,LYNET_OCT=@LYNET_OCT,NET_NOV=0,LYNET_NOV=@LYNET_NOV";
OLEDBupdateCom.Transaction = trans;
x = 10+ x;
OLEDBupdateCom.Parameters.Add(new OleDbParameter("@LYNET_APR", x));
OLEDBupdateCom.Parameters.Add(new OleDbParameter("@LYNET_MAY", dr["LYNET_MAY"]));
OLEDBupdateCom.Parameters.Add(new OleDbParameter("@LYNET_JUN", dr["LYNET_JUN"]));
OLEDBupdateCom.Parameters.Add(new OleDbParameter("@LYNET_JUL", dr["LYNET_JUL"]));
OLEDBupdateCom.Parameters.Add(new OleDbParameter("@LYNET_AUG", dr["LYNET_AUG"]));
OLEDBupdateCom.Parameters.Add(new OleDbParameter("@LYNET_SEP", dr["LYNET_SEP"]));
OLEDBupdateCom.Parameters.Add(new OleDbParameter("@LYNET_OCT", dr["LYNET_OCT"]));
OLEDBupdateCom.Parameters.Add(new OleDbParameter("@LYNET_NOV", dr["LYNET_NOV"]));
//OLEDBupdateCom.ExecuteNonQuery();
//dr.AcceptChanges();
}
OLEDBda.Update(dt);
//dt.AcceptChanges();
//OLEDBda.UpdateCommand = combil.GetUpdateCommand();
//OLEDBda.Update(ds);
trans.Commit();
ds.AcceptChanges();
}
plzzzzzzzzz help
Regards
ruwandi
rkherath
|
|
|
|
|
How can I update columns of three tables in on sql statement
|
|
|
|
|
Wrap it in a transaction - That way either all updates work, or if one fails then they all fail. From the point of view of any other process querying the database it will only see the complete set of changes, or no change at all.
|
|
|
|
|
Specify which table you want to update by using a JOIN. Here is an example of 4 tables, and an UPDATE to three of them.
CREATE TABLE people
( personID INTEGER
, personame VARCHAR(40)
, jobID INTEGER
);
CREATE TABLE addresses
( addressID INTEGER
, address VARCHAR(80)
);
CREATE TABLE jobs
( jobID INTEGER
, employerID INTEGER
, jobname VARCHAR(25)
);
CREATE TABLE employers
( employerID INTEGER
, employername VARCHAR(50)
, addressID INTEGER
);
UPDATE ((( people AS P
INNER JOIN jobs AS J ON P.jobID=J.jobID )
INNER JOIN employers AS E ON J.employerID=E.employerID)
INNER JOIN addresses AS A ON E.addressID=A.addressID)
SET jobname='Dishwasher'
, employername='McDonalds'
, address='510 Broadway'
WHERE personame='John Doe';
Hope this helps.
David
|
|
|
|
|
I am new to sql
Please help in writing INSERT and UPDATE triggers
for five tables, of which 4 has primary key and one has foriegn key
Samples would help a lot
Thanks
Sathi
|
|
|
|
|
Have you even looked at the documentation? The standard documentation for SQL Server (known as "Books On-Line") includes many examples.
From the SQL Server Books On-Line: Create Trigger[^]
|
|
|
|
|
Thanks a lot
It was really helpfull
|
|
|
|
|
Does anyone know how to push a Basic (VBA) module into Access using an SQL interface?
I have:
- A utility I wrote that runs raw SQL commands against an (already existing) Access database. It uses ADODB.
- An SQL file that builds all my tables and indexes.
- An SQL file that builds my views and procedures.
- An SQL file that populates the database.
All I'm missing is a way to programatically (via my utility and a file of commands) push my VBA modules and my forms and reports into the database. Right now I have to manually import them or drag them from the old version to the new version.
Any ideas?
DQNOK
|
|
|
|
|
i am creating a basic web application to try and further understand the asp.net that i have been learning in my course..
i have got a month to wait before i get onto the next section of the course and want to get stuck in..
does anyone know.. or could anyone donate some code in the meantime for the following..
i have a basic user sign up webform with ;
first name
second name
email address
band name
password
d.o.b
i eventually want the user sign up to be written to my version of sql server express 2005
so i can have a record of the users and so i can enable users to sign in.. greet them with their name and bandname and then further post any gigs that they wish onto a calender..
i dont know where to start or how complicated a task it actually is.. i think i will also have to create some form of admin for the database to manage and delete records etc..
any advice or help would be fantastic..
but for now i will just keep scouring the web
cheers...
John Michael Kinsella
kinsellajohn@hotmail.com
|
|
|
|
|
Hello,
Is it possible to link to a server though SQL Server's Linked Server capabilities from another Server?
If so, what do I need to do?
I am using MS SQL 2005 Dev.
Rad
rad
|
|
|
|
|
Hi Guys,
Please,help with this.I am using bulk insert to upload a text file but i receive the following error message :
System.Data.SqlClient.SqlException was caught
Message="Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 2, column 13 (EFFECTIVE_DATE).\r\nBulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 3, column 13 (EFFECTIVE_DATE).\r\nBulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 4, column 13 (EFFECTIVE_DATE).\r\nBulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 5, column 13 (EFFECTIVE_DATE)."
Thanks in Advance.
|
|
|
|
|
i have searched a range or string from a help of this forum, but now i want to make this range search depending on the "Extension" column and "Numkey" column here is the code for searching the string please extend it for me to make it possible.
select * from property
where Cast(Substring(Attrib_code,5,5) as bigint)
between 00274 And 01189
here is the query that work for for selecting records with Numkey and extension
(select * from Properties where Extension = 2 And Num_Key = '0196')
i would like to get all this results in one,
All the records with Nem_key='0196', who are in extension = 2
from a range 00274 and 01189.
Note: the code of searching the string is working very well, i would like to combine these searches.
Please Help
Vuyiswa
|
|
|
|
|
I think this is pretty easy, unless I don't understand what you want to do.
Wouldn't this work?
select * from property
where Extension = 2 And Num_Key = '0196' and
Cast(Substring(Attrib_code,5,5) as bigint) between 00274 And 01189
Hope that helps.
Ben
|
|
|
|
|
Yes man the code works but i want it to depent on two fileds for its results "Extension" and "Num_Key".
it must display between 00274 and 01189 but based on the Extensions and Num_keys
help me man
thanks
Vuyiswa
|
|
|
|
|
I guess I don't understand then. All three of those things are in the where clause. First you limit the result set by Extension and Num_key, then you limit it by display between 00274 and 01189. I am pretty sure the query I gave does what you are asking. It is doesn't please try to explain what you want again.
Ben
|
|
|
|
|
Thanks Ben for your reply and patience. the code is correct it does not return an error but it return an Empty table.
i tested
select * from property
where Extension = 2 And Num_Key = '0196' separately and it returned 1239 Rows. but when i combine it with the code you gave me
select * from property
where Extension = 2 And Num_Key = '0196' and
Cast(Substring(Attrib_code,5,5) as bigint) between 00274 And 01189
it shows an Empty table by only displaying the Column names only
Please help man
thanks
Vuyiswa
|
|
|
|
|
Well, then my guess would be in those 1239 rows there aren't any that have a value between 274 and 1189.
Try this
select * from property
where Extension = 2 And Num_Key = '0196'
order by attrib_code
That way you should be able to see if you have any between 274 and 1189
Hope that helps.
Ben
|
|
|
|
|
Thanks man when i run it it gives me 1329 records.
Vuyiswa
|
|
|
|
|
i mean the code you just gave me
select * from property
where Extension = 2 And Num_Key = '0196'
order by attrib_code
Vuyiswa
|
|
|
|
|
So the question is in those rows that are returned look at the attrib_code and tell me if you see any in the range you are looking for. I am guessing that you will not find any in the range you said you wanted.
Ben
|
|
|
|
|
Thanks man for your reply,i have used the wrong column, i should have used Lis_key, and i used Attrib_key, so when i enter that range its good its showing results. thanks man you are a star . my mistake for the wrong column. i saw your profile, i just uploaded my photo. am 25 turning 26 in September this year thanks man.
kind regards
Vuyiswa
Vuyiswa
|
|
|
|
|
i mean the code you just gave me
select * from property
where Extension = 2 And Num_Key = '0196'
order by attrib_code
Vuyiswa
Vuyiswa
|
|
|
|
|
Thank you man , my mistake it wasnt Attribute code column it was supposed to be Lis_Key. remember yesterday we did the Attribute code, thanks a lot man for you time, i will rate you as my mentor
kind regards
Vuyiswa
Vuyiswa
|
|
|
|