|
The funny thing is that i try to refresh the connection after i got the login message Visual Studio Server Explore return this message :
QueryInterface for interface IOleServiceProvider failed.
and then the connection on the treeview expire
when before the compilation the connection test was
succesfull.
Plus i can see everything from the Database from visualstudio ,Tables records . Everything.
Do you think my problem is that i am running on Win2K SP2 Italian and VisualStudio is English so MSSQL (MSDE) ?????
|
|
|
|
|
Plus after the connection is expired from Server Explorer , visual studio show me an empty database, but with all tables and fields, but not data.
|
|
|
|
|
This the part of the script that grants the access to the database.
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
if not exists (select * from dbo.sysusers where name = N'ASPNET' and uid < 16382)
EXEC sp_grantdbaccess N'ASPNET', N'ASPNET'
GO
/****** Object: User dbo Script Date: 3/7/2002 1:52:45 PM ******/
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_accessadmin', N'ASPNET'
GO
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_backupoperator', N'ASPNET'
GO
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_datareader', N'ASPNET'
GO
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_datawriter', N'ASPNET'
GO
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_ddladmin', N'ASPNET'
GO
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_denydatareader', N'ASPNET'
GO
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_denydatawriter', N'ASPNET'
GO
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_owner', N'ASPNET'
GO
/****** Object: User ASPNET Script Date: 3/7/2002 1:52:45 PM ******/
exec sp_addrolemember N'db_securityadmin', N'ASPNET'
GO
|
|
|
|
|
I just finished right now to try the Runtime connecting way:
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection sqlconnectContactMgmt = new SqlConnection("server=(local);database=Contacts;Trusted_Connection=yes");
SqlDataAdapter sqladaptContactMgmt = new SqlDataAdapter("select * FROM Contacts",sqlconnectContactMgmt);
DataSet dsContacts = new DataSet();
// until now all the breakpoints are executed okay
// this generate the server error :
//Server Error in '/Ch05' Application.
//----------------------------------------------------------
//Login failed for user 'PRESARIO1692\ASPNET'.
//Description: An unhandled exception occurred during the
// execution of the current web request. Please review the
//stack trace for more information about the error and
//where it originated in the code.
//Exception Details: System.Data.SqlClient.SqlException:
//Login failed for user 'PRESARIO1692\ASPNET'.
sqladaptContactMgmt.Fill(dsContacts,"Contacts");
DataGrid1.DataBind(); // never reach this point
}
|
|
|
|
|
|
You mean This ???
initial catalog=Contacts;integrated security=SSPI;persist security info=False;user id=ASPNET;workstation id=PRESARIO1692;packet size=4096
Connection String property of the sqlConnection of my web application.
Should i use another user id ?
which one ?
I tryed but i got the exactly the same error from the same
user id even i changed it !!!!
|
|
|
|
|
MSDE be default uses Integrated Security, thus it will use windows security. No need to give user/pass.
Here is mine for a default MSDE (the default one included with VS.NET i should rather say):
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=LOCALHOST\VSdotNET;Packet Size=4096;Workstation ID=LOCALHOST;
DAMN emoticons !!!!!
|
|
|
|
|
I have little experience with arrays and would like some help. I am querying an LDAP directory via a ActiveX component called AdvLDAP from Aspfusion.net. The code is below. What I want to do is be able to perform IF THEN statements on the variables in the array and insert some into a table. You can see from the LDAP.Attributes line what attributes I am returning. For instance, I want to return the attribute and value of "User-Suspend" so that I can perform something like "IF User-Suspend = "Y" THEN"...any help is appreciated.
===========================================
dim LDAP
set LDAP = Server.CreateObject("AdvLDAP.LDAP")
LDAP.ServerName = "10.1.58.25"
LDAp.Port = "389"
LDAP.UserName = "tssacid=dsldap"
LDAP.Password = "*******"
LDAP.DN "c","us"
LDAP.DN "o","upb"
LDAP.DN "host","CAICCI"
LDAP.DN "tssadmingrp","Acids"
LDAP.DN "tssacid",""&userID&""
LDAP.Attributes = "Name;user-type;user-suspend"
LDAP.Filter = "objectclass=*"
LDAP.Scope = "Base"
Set Result = LDAP.Query()
if (LDAP.IsError = 1) then
Response.Write LDAP.ErrorReason & "<br>"
else
%>
<TABLE ALIGN=center BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR bgcolor="black">
<%
Dim cols,rows,Arr()
cols = 0
rows = 0
for each Member in Result%>
<TD bgcolor="black" width="100%">
<font color="white"><%=Member.Attributes%>
</font></b></TD>
<%cols = cols+1
if (cols = 1) then
set Links = Member.ValuesList()
for each item in Links
rows = rows + 1
next
set Links = Nothing
end if
next
%>
</TR>
<%
ReDim Arr(cols, rows)
c1 = 0
for each Member in Result
r1 = 0
set Lnks = Member.ValuesList()
for each Item in Lnks
val = ""
itm = Item.Value
for i = 0 to ubound (itm)
val = val & itm(i)
if (i <> ubound (itm))then
val = val & ", "
end if
next
Arr(c1,r1) = val
r1 = r1 + 1
next
set Lnks = Nothing
c1 = c1+1
next
for rw = 0 to rows-1%>
<TR>
<%for cl = 0 to cols-1%>
<TD><%
if (Arr(cl,rw) <> "")then
Response.Write Arr(cl,rw)
else
Response.Write "-"
end if%></TD>
<%next%>
</TR>
<%next%>
</TABLE>
<%
End If
%>
|
|
|
|
|
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
|
|
|
|
|