|
First, shouldn't you call your BindData() AFTER there is postback instead of BEFORE, i.e.
if(Page.IsPostBack)
{
BindData();
}
Second, you have four queries in your SQL statement, with the second to fourth queries not needing any parameters, which means whatever your PartNumberInput is they're still going to be displayed and always the same. I'm assuming whatever binds to your Tables[1] to Tables[3] will always be shown in this case.
Does that help?
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Okay, I think I know what you mean. Here is what I have now:
private void BindData()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
<br />
<br />
string SQLString = "SELECT p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath FROM parts p INNER JOIN PartTypes pt on pt.ID =p.PartTypeID LEFT JOIN DraftingData dd on dd.PartID = p.ID WHERE p.PartNumber = @PartID;SELECT w.weight, wt.Description AS wtDescription, p.PartNumber from weights w INNER JOIN weighttypes wt on wt.ID = w.weighttypeid INNER JOIN Parts p on w.PartID = p.ID WHERE p.PartNumber = @PartID;SELECT c.cost, p.PartNumber, ct.Description AS ctDescription from Costs c INNER JOIN Parts p ON c.PartID = p.Id INNER JOIN CostTypes ct on ct.Id = c.CostTypeID WHERE p.PartNumber = @PartID; SELECT s.SubPartID, s.Quantity, s.Sequence, p.PartNumber FROM SubParts s INNER JOIN Parts p ON s.PartID = p.Id "; <br />
<br />
<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds);<br />
<br />
<br />
ds.Tables[1].TableName = "Weights";<br />
ds.Tables[2].TableName = "Costs";<br />
ds.Tables[3].TableName = "Subparts";<br />
<br />
dgParts.DataSource = ds;<br />
dgParts.DataBind();<br />
txtPartNumberInput.Text = "";<br />
}
So when the user enters the data the grid comes back perfect. Just how I want it. BUT when I hit the Edit button, I get back to the problem of bogus data.
public void dgParts_edit (object sender, DataGridCommandEventArgs e)<br />
{<br />
dgParts.EditItemIndex = e.Item.ItemIndex;<br />
BindData();<br />
}
So I'm still not sure what I am doing wrong.
|
|
|
|
|
I'm not exactly sure what you meant by bogus data.
Do you mean the child tables are showing the wrong data?
Try setting the CurrentRowIndex of the datagrid instead.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
I'm looking for the SQL equivalent to Scott Meyer's "Effective C++; 50 Specific ways to improve your pograms and designs".
Thanks,
Dave
Rocket science is more fun when you actually have rockets - US Navy ad
|
|
|
|
|
SQL For Smarties[^] is one of the best SQL books I've seen.
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
hi
how to extract column names of a perticular table
can anyone tell me the query for that
Thanks
Thanks
|
|
|
|
|
|
Thanks for help
but its not working i dont know whats the proble
Actually i am using ms access database
where GeometryData.mdb is my database name and iges_data is my table name
Please help me
Thanks
|
|
|
|
|
hello,
try out ..
one of these..
1. sp_columns tablename
2. select name from syscolumns where id = object_id('tablename')
vivek
|
|
|
|
|
|
Hi, I'm beginner to .NET...
I'm trying to access an Oracle Database using a ASP.Net webservice with C#.... I'm using VS.NET 2005 and Oracele 10g...
Created an System DSN using the Oracle ODBC driver
I tried using an OdbcConnection
String constr = String.Format("DSN={0};UID={1};PWD={2};", "TEST", "user", "passwd");
con = new OdbcConnection(constr);
con.open();
This code works fine with a C# client program, but when I tried it with the webservice I get the following error...
Error[IM003] Specified driver could not be loaded due to sytem error 5(Oracle in OraClient10g_home1)
ny ideas? Am I missing something...?? Plz help if possible...
Mahesh
|
|
|
|
|
Are you importing the correct namespaces in your webservice
You may also have to install an oracle client driver I've had issues with this in the past.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Hi,
Yes, I'm using System.Data.Odbc and I hav the Oracle client for 10g rel 1 installed... The connection opens correctly when I use the code in a C# windows application... I only get the error when using it in the webservice....
|
|
|
|
|
Try to determine what account the webservice runs under. If it is the default one called ASPNET it likely does not have the needed permissions for accessing the system DSN. That's what I'd look at first.
Chris Meech
I am Canadian. [heard in a local bar]
When no one was looking, every single American woman between the ages of 18 and 32 went out and got a tatoo just above their rumpus. [link[^]]
|
|
|
|
|
Hi Chris,
Thx.... That was the issue I gave the ASPNET user access to my oracle home folder and its subfolders and now the code works.... I had issues when I tried using the Oracle .NET provider... But this solution corrected everything....
Thx everybody....
Mahesh
|
|
|
|
|
Glad that worked. I should have pointed you to my only article, cause I ran into the permissions thing with it as well. And it took a bit of time to figure out how to deal with the permissions.
Chris Meech
I am Canadian. [heard in a local bar]
When no one was looking, every single American woman between the ages of 18 and 32 went out and got a tatoo just above their rumpus. [link[^]]
|
|
|
|
|
hi all
i'm hoping i'm right since i've put a lot of time into building the c# scripts to generate the select statement...
SELECT Customers.Cust_Cd, Titles.Title_Description, Customers.Cust_Name, Customers.Cust_Surname, Customer_Types.Cust_Type_Description,
Customers.Cust_Birthdate, Staff.Staff_Name, HomeFax.CCI_Area_Cd + HomeFax.CCI_Number as HomeFaxNumber, HomeNo.CCI_Area_Cd + HomeNo.CCI_Number as HomeNumber, HomeEmail.CCI_Email as HomeEmail, Mobile.CCI_Area_Cd + Mobile.CCI_Number as CellNumber, WorkFax.CCI_Area_Cd + WorkFax.CCI_Number As WorkFaxNumber, WorkNo.CCI_Area_Cd + WorkNo.CCI_Number as WorkNumber, WorkEmail.CCI_Email as WorkEmail
FROM Customers LEFT OUTER JOIN
Titles ON Customers.Cust_Title_Cd = Titles.Title_Cd LEFT OUTER JOIN
Customer_Types ON Customers.Cust_Type_Cd = Customer_Types.Cust_Type_Cd LEFT OUTER JOIN
Staff ON Staff.Staff_Cd = Customers.Cust_Staff LEFT OUTER JOIN
Customer_Contact_Info HomeFax ON HomeFax.CCI_Cust_Cd = Customers.Cust_Cd
and HomeFax.cci_Contact_Type_Cd = 3
and HomeFax.CCI_Context = 'Home' left outer join
Customer_Contact_Info WorkFax on Customers.Cust_Cd = WorkFax.CCI_Cust_Cd
and WorkFax.cci_contact_type_cd=3
and WorkFax.cci_context='Work' left outer join
Customer_Contact_Info HomeNo on Customers.Cust_Cd = HomeNo.CCI_Cust_Cd
and HomeNo.cci_contact_type_cd=2
and HomeNo.cci_context='Home' left outer join
Customer_Contact_Info WorkNo on Customers.Cust_Cd = WorkNo.CCI_Cust_Cd
and WorkNo.cci_contact_type_cd=2
and WorkNo.cci_context='Work' left outer join
Customer_Contact_Info Mobile on Customers.Cust_Cd = Mobile.CCI_Cust_Cd
and Mobile.cci_contact_type_cd=2
and Mobile.cci_context='Mobile' left outer join
Customer_Contact_Info HomeEmail on Customers.Cust_Cd = HomeEmail.CCI_Cust_Cd
and HomeEmail.cci_contact_type_cd=1
and HomeEmail.cci_context='Home' left outer join
Customer_Contact_Info WorkEmail on Customers.Cust_Cd = WorkEmail.CCI_Cust_Cd
and WorkEmail.cci_contact_type_cd=1
and WorkEmail.cci_context='Work'
Where Customers.Cust_wantEmail = '1' and(staff.Staff_name = 'rene' or staff.Staff_Name = 'maryke')
go
Am i right to say that i can't speed up the select statement any more...?
He who laughs last...
|
|
|
|
|
|
Yes, thanks.
i'm not complaining about the speed that it is currantly running at, i just wanted to know if it would be faster if i used the UNION <in some="" way="" or="" another=""> or if i'm getting the full speed by just using the select with the joins as it is. I'm not that familiar with the UNION statement. But from what i can make out is that it is more than one select statement, does that mean that the UNION might even slow the select statement down?
i don't know...
He who laughs last...
|
|
|
|
|
Why don't you build it by various methods then run it in Query Analyser and look at the Execution Plan.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Hi
I am Unable to access database
such as SqlServer for an application.
please get me an Procedure or Code
OK...
Bye.........
G.Nagaraju<b>
G.Nagaraju
|
|
|
|
|
|
i had combobox that binding to sqldataadapter so when i choose item form combobox(selectedindexchange event) another adapter are fire and fill table in data set then i update the second adapter so the data in the combobox may have to be changed so i want to make the data in the combobox uptodate when i try to clear sqladapter1 that fill combobox and fill it again an error happened taht the second adapter have parameter and didn't find value to assign to that parameter (adapter 2 was take the paramtere from combobox) do i try to before clear adapter1 to put combobx item in var to use to fill the second adapter but the error still occurred what i do to reslove that error
thanks.................
ma_refay
|
|
|
|
|
i want to know the order to reterive the machine name and the instance of sql server name to use in my connection to create general connection string that automatically put theses items in connection string so i mustn't change connection string when run appliction on another machine
ma_refay
|
|
|
|
|