|
I don't know how this relates to your problem - perhaps the full stack trace would be more helpful - but there are a number of things that stand out as being, at best, a little odd.
You are instatiating a form during the construction phase of your user control - Why do you need this form? Why not construct it just as you are about to use it? That would seem to be a better design.
Although you receive some kudos for using the Enterprise Library, you are not using it in a Dal - you're just dumping the data access in the form like the designer would - This is great for a simple throw away app you are only going to use one, but for an enterprise application data access should be tucked away in a DAL (Data Access Layer). The Enterprise Library DAAB on its own is not a DAL, it just makes the creation of a DAL much easier.
Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?
My: Website | Blog
|
|
|
|
|
The problem is not with either the DAAB or the Visual Designer. They are functioning as intended and doing just what you are asking them to do.
The problem as Colin points out is with your design. When your control is being rendered in the designer it is trying to instantiate the form. Again, as Colin suggests, a better approach may be to remove the form from the creation process and move the DAAB to a DAL.
|
|
|
|
|
Folks,
We had a server crash, but were able to restore our database files from the disk. Having rebuilt our server, we would now like to restore the database, but we're unable to figure out to re-attach the .MDB file, as it was not detached prior to the crash.
We're using SQL v7.0.
Any help would be greatly appreciated.
TIA!
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Actually, it is an .mdf file - .mdb is a msaccess file extension.
You can use sp_attach_db , sp_attach_single_file_db , or even see here[^]
CREATE DATABASE [ATestDB] ON (FILENAME = 'C:\TestPath\ATestDB_Data.MDF') FOR ATTACH
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
EricDV wrote: Actually, it is an .mdf file
Sorry, my bad...
EricDV wrote: You can use sp_attach_db, sp_attach_single_file_db
Per MSDN:
Remarks<br />
sp_attach_db should only be executed on databases that were previously detached from the database server using an explicit sp_detach_db operation.
As I mentioned in my post, the file(s) were not previously detached.
Here's what we've tried so far...
<br />
Attempt 1 (Strike 1): TRIED TO EXECUTE IN QUERY ANALYZER<br />
EXEC sp_attach_db @dbname = 'NewDatabase', <br />
@filename1 = 'c:\mssql7\data\ArchiveData.mdf', <br />
@filename2 = 'c:\mssql7\data\ArchiveLog.ldf'<br />
<br />
SERVER MESSAGES:<br />
Server: Msg 9004, Level 21, State 3, Line 1<br />
The log for database 'NewDatabase' is corrupt.<br />
Connection Broken<br />
<br />
(Continued) ISSUE:<br />
The log file is corrupt, so I tried to attach the mdf file to a new database using the single file attach method.<br />
<br />
Attempt 2 (Strike 2):TRIED TO EXECUTE IN QUERY ANALYZER<br />
EXEC sp_attach_single_file_db @dbname = 'NewDatabase', <br />
@physname = 'c:\mssql7\data\ArchiveData.mdf'<br />
<br />
SERVER MESSAGES:<br />
Server: Msg 945, Level 14, State 2, Line 1<br />
Database 'NewDatabase' cannot be opened because some of the files could not be activated.<br />
Server: Msg 1813, Level 16, State 2, Line 1<br />
Could not open new database 'NewDatabase'. CREATE DATABASE is aborted.<br />
<br />
Attempt 3 (Strike 3 --- Struck OUT): tried to fool SQL Server by switch mdf files. <br />
I created a brand new database called Archive.<br />
I detached the database.<br />
I renamed the Archive_Data.mdf to Archive_DataOld.mdf<br />
I applied the switch by renaming the AchiveData.mdf to Archive_Data.mdf <br />
I left the brand new log file alone.<br />
I attempted to attach the database<br />
<br />
EXEC sp_attach_db @dbname = 'Archive', <br />
@filename1 = 'c:\mssql7\data\Archive_Data.mdf', <br />
@filename2 = 'c:\mssql7\data\Archive_Log.ldf'<br />
<br />
<br />
also tried<br />
<br />
EXEC sp_attach_db @dbname = 'NewDatabase', <br />
@filename1 = 'c:\mssql7\data\Archive_Data.mdf', <br />
@filename2 = 'c:\mssql7\data\Archive_Log.ldf'<br />
<br />
SERVER MESSAGES:<br />
Changed language setting to us_english.<br />
Server: Msg 5173, Level 16, State 2, Line 1<br />
Cannot associate files with different databases.<br />
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Hi, I have an ASP.NET/C# application in which the user enters a part number, hits the command button and the grid populates info about that part.
I think something is wrong with my SQL statement, as when my grid loads in the page, data is showing before I've entered anything.
Here is a snippet of the code:
private void Page_Load(object sender, System.EventArgs e)
{<br />
if(!Page.IsPostBack)<br />
{<br />
BindData();<br />
}<br />
}<br />
private void BindData()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
<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;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; SELECT s.SubPartID, s.Quantity, s.Sequence, p.PartNumber FROM SubParts s INNER JOIN Parts p ON s.PartID = p.Id "; <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 />
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 />
}
Does anyone see what I'm missing?eID LEFT JOIN parts p on p.id = w.PartID WHERE p.PartNumber = @PartID;SELECT c.cost, ct.Description AS ctDescription, p.PartNumber from Costs c INNER JOIN Parts p ON c.PartID = p.Id LEFT 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";
SqlCommand cmd = new SqlCommand();
cmd.Connection = new SqlConnection(strConnectSQL);
cmd.CommandText = SQLString;
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);
ds.Tables[1].TableName = "Weights";
ds.Tables[2].TableName = "Costs";
ds.Tables[3].TableName = "Subparts";
dgParts.DataSource = ds;
dgParts.DataBind();
txtPartNumberInput.Text = "";
}
I've been going crazy with this. Can someone help me fix one or the other?
|
|
|
|
|
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...
|
|
|
|
|