|
Hi I have Visual Studio.NET Beta 2 on my computer.
I dowloaded Project from Code Project that might be very usfull for me as a beginner such as:
http://www.codeproject.com/useritems/spgen.asp
Trying to open the sources I get "invalid RESX input' error double clicking the frmMain.cs and "SQLDMO could not be found" message (I have registarted SQLDMO.dll).
What should I do?
Please help
Thanks
|
|
|
|
|
|
I wanted my application to start soon after the user logs onto the PC and therefore created a key iunder
HKM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
the application does start up thats ok
the problem is now soon as
-the user logs in the aplication starts up,so far so good
-there is a ado connection that is done in the app class ...
[this works fine during normal execution]
-however when this is done soon after OS startup a run time error is thrown...
is it because ADO drivers are not initialised yet or something like that
how do i overcome this.
any advice would be a blessing
fordge
|
|
|
|
|
I want to try to help you, but I have a couple of questions that would help me to provide an answer:
1. What programming language is your app written in?
2. Does your app run fine when you start it post starup--that is, once you have logged in and all services are started and then you go and start it manually, does it work OK?
3. If the answer to question 2 is no, then have you steped through it to the point of failure with the debugger? And if so, what does it say?
I've never run an application at login that uses ADO, but I do believe that all applications listed under "Run" are run after all system services have started. I could be wrong. Let me know your answers and we'll go from there.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Sorry for not explaining my mail properly
These are the answers to your queries -
1.The app is written in VC,but maybe the problem could exist if written in VB too.
2.Application works fine in post startup,no problem at all.
3.therefore no debugger error.....Just a big big runtime error..
|
|
|
|
|
This is me again...
I initially started this message thread as I had a problem getting the ado connection at startup....
i had written the exe path in a key in registry
"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\\Run"...though the exe startsup an ado connection error is thrown if ado connection is tried in InitInstance of the app
ive finally got it right..consider the following code
-----------------------------------
CoInitializeEx(NULL, 0x02);
try{
_ConnectionPtr mpDBConnection;
mpDBConnection.CreateInstance(__uuidof(Connection));
HRESULT hRes=mpDBConnection->Open(_T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database\\TrialDB.mdb;Persist Security Info=False"),"","",adConnectUnspecified);
CStartUpDlg dlg;
m_pMainWnd = &dlg;
...
...
..
-----------------------------------
this works fine when normally executed and the database connection is ok.
however in startup when saying "database\TrialDB.mdb" instead of refering to the relative path of the application it assumes it as being in "c:\" drive.....
and therefore looks for the database in "c:\database\TrialDB.mdb" ..
and obviously as there is no database there the connection fails.
however if the code is changed tohaving the follwoing lines occure before the connection is opened like below
-----------------------------------
CoInitializeEx(NULL, 0x02);
try{
CStartUpDlg dlg;
m_pMainWnd = &dlg;
_ConnectionPtr mpDBConnection;
mpDBConnection.CreateInstance(__uuidof(Connection));
HRESULT hRes=mpDBConnection->Open(_T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database\\TrialDB.mdb;Persist Security Info=False"),"","",adConnectUnspecified);
...
...
..
-----------------------------------
the conection works fine in startup as well..
but unfortunately as i need to do the database connection before I create the dialog object..... the question persists...
<b>1.Why cant i get the relative path in startup????
2.Please suggest an alternative solution to get the relative path....
i mean besides using get CurrentDirectory() and that kind of stuff </b>
Consider for example when we create a shortcut
we can specify a 'start in' directory
and all relative paths refer to this strt in directory right??
<b>is there anywhere i can specify such a 'start in' directory for an application in registry!!!</b>
if there is any other method to get the relative path of the app please tell me...
|
|
|
|
|
I am doing a join with three tables and I can't seem to get distinct rows. I know what the problem is, but I'm not enough of a SQL person to know the proper syntax. The tables are Customers, CustomerRelationships, CustomerRelationshipsLU (as in Look Up). I get the CustomerID, FirstName, and Last Name from the Customers Table. The CustomerRelationships table tells me how one customer is related to another (e.g. wife, son, etc.). I need to get the name of the relationship and not the ID which is why I am joining the CustomerRelationshipsLU table as well. Here is the statement I am using currently:
SELECT TA_Customer.Customer_ID,
TA_Customer.FirstName,
TA_Customer.LastCompanyName,
TA_CustomerRelationshipsLU.Description
FROM TA_CustomerRelationships INNER JOIN TA_CustomerRelationshipsLU ON
TA_CustomerRelationships.RelationshipID =
TA_CustomerRelationshipsLU.RelationshipID CROSS JOIN
TA_Customer
WHERE (TA_Customer.CustomerID = '101') AND (TA_CustomerRelationships.CustomerID = '101')
Youre eyes are not deceiving you--there is a CustomerID and a Customer_ID (notice the underscore _ in the second). CustomerID represents what you might think of as a customer group (e.g. family, business, etc.) whereas Customer_ID represents the individual ID for every customer--as in person.
My query returns:
155611 Jane Jones Wife
155611 Jane Jones Son
155612 Willy Jones Wife
155612 Willy Jones Son
DISTINCT doesn't help for obvious reasons. Does this make sense to anyone? Any help would be appreciated.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
yah well the point is the result set u got IS distinct if u look at all the returned fields
maybe u have to select the first part into a temp table and do a select distinct from there
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
Can you provide some SQL? I'm not sure how to do what you're talking about or how it would fix my problem.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
in terms of ur above example what exactly would u want to see in the result set?
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
I would like to see:
155611 | Jane | Jones | Wife
155612 | Willy | Jones | Son
Thanks.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I think the problem you are having is the cross join on relationships. There should be no reason why you would get Jane Jones as both Wife and Son. Can you post the tables? For example, give me two or three lines of data for each of the three tables, adn I can look more closely at the query you have written.
Jeremy
Jeremy Oldham
|
|
|
|
|
Sounds good. I appreciate your help.
Here's a select on the top level CustomerID (which is '101' in this case)for the TA_Customer table (I used a reduced set of columns for brevity on this particular tables. The ones below it are, however, complete):
TA_Customer
------------
Customer_ID CustomerID LastName FirstName
155603 101 Jones Bob
155611 101 Jones Jane
155612 101 Jones Willy
TA_CustomerRelationships
-------------------------
CustomerID Customer_ID1 Customer_ID2 RelationshipID
101 155603 155611 2
101 155603 155612 3
TA_CustomerRelationshipsLU
---------------------------
RelationshipID Description
1 Husband
2 Wife
3 Son
4 Daughter
5 Father
6 Mother
7 Grandfather
8 Grandmother
9 Uncle
10 Aunt
11 Nephew
12 Niece
13 Cousin
For your convenience, here is the original query:
SELECT TA_Customer.Customer_ID,
TA_Customer.FirstName,
TA_Customer.LastCompanyName,
TA_CustomerRelationshipsLU.Description
FROM TA_CustomerRelationships INNER JOIN TA_CustomerRelationshipsLU ON
TA_CustomerRelationships.RelationshipID =
TA_CustomerRelationshipsLU.RelationshipID CROSS JOIN
TA_Customer
WHERE (TA_Customer.CustomerID = '101') AND (TA_CustomerRelationships.CustomerID = '101') AND
(TA_Customer.Customer_ID <> 155603)
Notice I added in an extra 'AND' clause. I only want to return the subordinate records. The top level record is the one for "Bob" whose Customer_ID is 155603.
As a reminder, I want the output to be this:
155611 Jane Jones Wife
155612 Willy Jones Son
Thanks for your help.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Try the following and let me know how it worked.
<br />
Select TA_Customer.Customer_ID, TA_Customer.FirstName, <br />
TA_Customer.LastName, TA_CustomerRelationshipsLU.[Description]<br />
FROM TA_Customer<br />
INNER JOIN (<br />
--Gives you the Relationships for the individual<br />
Select Customer_ID2, RelationshipID<br />
from TA_CustomerRelationships<br />
WHERE Customer_ID1 = 155603<br />
AND CustomerID = 101<br />
) b <br />
ON TA_Customer.Customer_ID = b.Customer_ID2<br />
INNER JOIN TA_CustomerRelationshipsLU<br />
ON b.RelationshipID = TA_CustomerRelationshipsLU.RelationshipID<br />
Jeremy Oldham
|
|
|
|
|
Sheesh! Just when I think I'm starting to get better at SQL, somebody shows me a query like this. I have no idea what exactly is going on in this query, but it worked like a charm. Thank you so much for your help. I really appreciate it.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Well let me give you a quick description.
First, I wanted to get only the customer numbers we needed that are related to the customer 155603 and is in the correct Customer Group 101. I did this be creating the following query:
--Gives you the Relationships for the individual<br />
Select Customer_ID2, RelationshipID<br />
from TA_CustomerRelationships<br />
WHERE Customer_ID1 = 155603<br />
AND CustomerID = 101
This query returns all the customers related to the Customer ID 155603 and within his group, as well as their relationship id.
Now all I needed to do is find out who those customers were (by their customer id) and what those relationships were (by relationID).
I did that by joining the TA_Customer table with the subquery which gives me the related customers information, and then joining the TA_CustomerRelationshipsLU table with the subquery which gives me the relation names.
I hope this helps explain the query a little bit.
Glad I could be of help!
Jeremy Oldham
|
|
|
|
|
Howdy all,
I'm using C# and ADO.NET to access an SQL Server Database, using SqlDataAdapter, DataSet et al.
What I want to do is create a new row, submit it to the database, and then retrieve the Identity field that SQL Server automagically generates. At the moment I have something like this:
string comm_str = String.Format( "SELECT Name, Image, IllustrationID FROM Illustrations");
SqlCommand comm = new SqlCommand( comm_str, m_sqlConn );
SqlDataAdapter da = new SqlDataAdapter( comm );
da.InsertCommand = da.SelectCommand.Connection.CreateCommand();
da.InsertCommand.CommandText =
@"INSERT INTO Illustrations (Name, Image) values(@Name, @Image)";
da.InsertCommand.Parameters.Add( "@Name", SqlDbType.Char, 0, "Name" );
da.InsertCommand.Parameters.Add( "@Image", SqlDbType.Image, 0, "Image" );
DataSet ds = new DataSet();
da.Fill( ds, "Illustrations" );
DataTable dt = ds.Tables["Illustrations"];
DataRow newRow = dt.NewRow();
newRow["Name"] = name.Length;
newRow["Image"] = imageBuffer;
dt.Rows.Add( newRow );
da.Update( ds, "Illustrations" );
ds.AcceptChanges();
newImageID = (int)newRow["IllustrationID"];
Now I think this code may look a little naieve, as I've cobbled it together from various books, but it does the job, apart from retrieving the IllustrationID field from the new record.
IllustrationID is set as an Identity field in the DB, so when a new record is inserted a value is generated by the DB. I'm guessing I need to update my DataSet, but I'm not sure how. Also, after updating my DataSet do I need to get a new DataTable, etc. or is this all handled automagically by ADO.NET.
Hope that makes some kind of sense and that someone has some advice for me!
TIA,
Pete
|
|
|
|
|
if ur using sql server u can use @@identity to get the last inserted record's id
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
I'm really looking for a solution using the C# DataAdapter and DataSet classes.
Thanks anyway
|
|
|
|
|
If you use a proper DataSet definition (Project->Add New Item, select DataSet, rename it, OK, drag-drop an element "Illustrations", add all your fields as sub-elements of that) then you can define one of those fields as AutoIncrement. Then it does all the work for you.
Paul
Pleasently caving in, I come undone - Queens of the Stone Age, No One Knows
|
|
|
|
|
Would that work with multiple users?
Say the last inserted record had an ID of 34, and user A gets his DataSet and inserts the record. meanwhile user B has inserted a record. if User A then checked the ID field would it be 35 or 36?
does that make sense?
|
|
|
|
|
In case anyone else needs help with this, there is a good article
HTH,
Pete
|
|
|
|
|
Is it possible to use ADO.NET from unmanaged c++?
Cheers,
Clint
|
|
|
|
|
Hi all, Got a bit of a problem here, I'm using C#/ASP.NET and am attempting to connect to a SQL source, wich is located on a server(SILICON) I have used the below connection syntax:
String strConnection = "server=SILICON; database=PositonTracker01; integrated security=true;";
SqlConnection objConnection = new SqlConnection(strConnection);
String strSQL = "SELECT FirstName, LastName, Country " + "FROM Analyst";
SqlCommand objCommand = new SqlCommand(strSQL, objConnection);
when i run this I get no data, just my html layout minus the data it should show, any suggestions?
|
|
|
|
|
- You've created a
SqlConnection object, but never opened it; - You've created a
SqlCommand object, but never executed it; - You haven't added any code to output the results of the query;
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|