|
I created a new web site project, and added a database to it. How do I setup a user id and password to access the specific database? I tried to "modify connection" but it said something about the username is not associated with a trusted SQL server connection.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Do you mean a username and password to access the SQL database through that rather than Windows Integrated Security (or whatever it's called), i.e. you specify the username and password to connect to the database?
If you're trying to connect through integrated security from ASP.NET chances are that that role has not been added to the permissions on the database. I.e. you need to create a user (server wide) for ASP.NET and then allow this user permission to read/write to the database in question.
A similar thing is required if you're using SQL Authentication rather than Integrated.
Of couse I may have misunderstood you completely.
|
|
|
|
|
The user Id/password that you use in the connection string relate to a user that is set up in the database. You would need to add a particular user to the database and set it up with the relevant permissions.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
What would cause SelectSingleNode to not retrieve the specified node?
I tried this:
XmlNode groupNode = root.SelectSingleNode("connectionStrings")
(root is "configuration").
I also tried this:
XmlNamespaceManager nm = new XmlNamespaceManager(doc.NameTable);
nm.AddNamespace("br", "C:\\web.config");
XmlNode groupNode = root.SelectSingleNode("//br:"+m_groupName, nm);
I always get a null response from SelectSingleNode, even though the section I'm looking for is really in the file.
Anyone?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Can you post the relevant snippet of your xml file?
|
|
|
|
|
It's a "typical" web.config file generated completely within the VS2005 IDE.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Ok, I think I might have got something working for you:
Xml File:
<?xml version="1.0"?>
<configuration xmlns:br="http://microsoft.com/schemas/VisualStudio/TeamTest/2006">
<br:connectionStrings>
<add name="SQL" connectionString="SQL" />
</br:connectionStrings>
<connectionStrings>
<add name="SQL2" connectionString="SQL2" />
</connectionStrings>
</configuration>
Code:
using System;
using System.Xml;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
XmlDocument dom = new XmlDocument();
XmlNamespaceManager manager = new XmlNamespaceManager(dom.NameTable);
manager.AddNamespace("br", "http://microsoft.com/schemas/VisualStudio/TeamTest/2006");
dom.Load("Web.config");
XmlNode groupNode = dom.DocumentElement.SelectSingleNode("br:connectionStrings", manager);
if (groupNode == null)
Console.WriteLine("(null)");
else
Console.WriteLine(groupNode["add"].Attributes["name"].Value);
}
}
}
Basically you need to construct the XmlNamespaceManager like you did but pass it into the SelectSingleNode function so that the function can use that object to resolve the namespaces in the XPath query.
Hope that helps, MS probably have their reasons for implementing it this way but it does seem a bit backwards, surely the NameTable should be populated from the xml file if that's where you read it from.
|
|
|
|
|
Thanks, I'll look at that when I get to work.
I initially tested my app with a simple web.config file. This file has your typical configuration section with a appSettings, connectionStrings, and a web.config section. That was working pretty well, so I decided to try it with one of our production web.config files (significantly larger and more complex). This file has the same stuff as the other one, as well as a configOptions section. A significant difference between the two files is that the production one has comments.
I'm trying to use Alvaro Mendez's read/write XML article [^] as a stepping off point because I haven't found ANY class that can handle the entire web.config file (none of them can read the connectionStrings section). His article doesn't do the namespace thing (and doesn't read the connectionStrings section), and seems to work fine on my small file, but chokes/pukes on the "real" config file.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
What I'm wondering is if this is a "standard" web.config why do you need namespaces?
|
|
|
|
|
I tried namespaces because of the stuff I found on the web regarding SelectSingleNode returning null. That didn't work any better than not using them. :/
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hmm, I did have a problem with SelectSingleNode before now that you mention it, the work-around I had was to use the indexer of the collection and check whether it was null .
Perhaps there's a bug in the 2005 version, the code I supplied worked on VS2008 with 3.5 framework, I can retarget it to compile against the 2.0 framework if it's any help.
|
|
|
|
|
I think I found my answer (detailed in another reply).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I figured out why it's not working. The web.config file in question has the following:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
It therefore has a problem finding any section contained within the configuration section. When I delete the xmlns attribute, my code works. Any idea how to ignore this programatically? .Net doesn't seem to have a problem parsing this web.config...
-- modified at 9:13 Tuesday 30th October, 2007
I have found references on google that claim the xmlns attribute isn't needed. I'm going to go ahead and delete the attribute and see if the associated web site still works.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Ok the problem seems to be that .NET 2.0 supports XPath 1.0 and XPath 1.0 does not support default namespaces. To get around this you can do the following (for some reason ):
Sample Xml File
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="SQL" connectionString="SQL" />
</connectionStrings>
</configuration>
Sample code:
using System;
using System.Xml;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
XmlDocument dom = new XmlDocument();
dom.Load("Web.config");
XmlNamespaceManager manager = new XmlNamespaceManager(dom.NameTable);
manager.AddNamespace("default", "http://schemas.microsoft.com/.NetConfiguration/v2.0");
XmlNode node = dom.DocumentElement.SelectSingleNode("default:connectionStrings", manager);
if (node == null)
Console.WriteLine("(null)");
else
Console.WriteLine(node.OuterXml);
}
}
}
Notice where I added the default namespace with a assigned name default , the documentation says that the default namespace should be string.Empty but this does not work, if you give it a namespace then it does.
Hopefully it'll support XPath 2.0 at some point.
|
|
|
|
|
Is there a way to create an application that can run under MACs?
|
|
|
|
|
Yeah - create the app on a PC, put your mac on the pc, and then run the app on the pc.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Take a look at the first google result for ".net mac osx"
|
|
|
|
|
Theoretically, MONO would work, but you would have to be careful with this because the MONO support for .NET is patchy in places.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a project to do called Multithreading and in this lab I have to creat A console application and start two threads simultaneously.
1. I created a console appleation and called it System.ThreadingDemo.
2. I need to creat a new static method called Counting. I'm not so sure how to go about it? I need feedback here.
3. In the new class, I need to add a using statment or the import statement for VB
to the System.Threading namespace? I need a feedback here!
4. In the new method, I need to creat a for loop that counts from 1 to 10? How would you do this?
5. within the New for loop, write out the current count and the ManagedThreadID for the current thread. I need a example here.
6. after writing out to the console, I need to sleep the current thread for 10 milliseconds.
I could use some feed back here.
7. I need to go back to the main method, and create a new ThreadStart delegate that points to the Counting method. Like what? what do they mean point to?
8. Now at this point I need Two threads, each pointing to the counting method.
How woud you code two more threads here?
This is a CODE example of a school project.... it needs work
after all said and done I have to Start both threads and join both threads to ensure that the application doesn't comloete until the threads are done. My code should look something like this:
Imports System.Threading
Class Program
Public Overloads Shared Sub Main()
Dim start As ThreadStart = New ThreadStart(AddressOf Counting)
Dim first As Thread = New Thread(starter)
Dim second As Thread = New Thread(starter)
first.start()
second.start()
first.join()
second.join()
console.Read()
End Sub
Shared Sub Counting()
Dim i As Integer
For i = 1 to 10 step i = 1
Console.WriteLine("Count: {0} - Thread: {1}" , -
i,Thread.CurrentThread.ManagedThreadID)
Thread.Sleep(10)
Next
End Sub
End Class
'You can copy this and use work with it, just let me know what you think.
-- modified at 8:37 Tuesday 30th October, 2007
tim637
|
|
|
|
|
Thanks for your code.
Was there a question somewhere?
If so, try make it more specific than "I need help!"
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: Was there a question somewhere?
If there is, I sure missed it
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I can see how the question could have been missed, but 1-8 is what I need help with, the code I put at the bottom was a example. Threading is such a big thing on a high level, its good to know.
tim637
|
|
|
|
|
please find the good resource related to threading..........
http://www.codeproject.com/csharp/threadinginnet.asp
http://aspnet35.blogspot.com/search/label/Threading
|
|
|
|
|
Thanks for the help.
tim637
|
|
|
|
|
Hello, I’m triying to load and execute managed code using methos as shown belong
<br />
SAFEARRAY * psArr;
SAFEARRAY * Param;<br />
CComPtr <ICorRuntimeHost> spRuntimeHost;<br />
CComPtr <_AppDomain> spAppDomain;<br />
CComPtr <IUnknown> spUnk;<br />
CComPtr <_MethodInfo> MI;<br />
CorBindToRuntimeEx( NULL, L"wks", STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN,<br />
CLSID_CorRuntimeHost ,<br />
IID_ICorRuntimeHost ,<br />
(void**)&spRuntimeHost);<br />
spRuntimeHost->Start();<br />
spRuntimeHost->CurrentDomain (&spUnk);<br />
spUnk->QueryInterface(&spAppDomain.p);<br />
try<br />
{<br />
MI = spAppDomain->Load_3(psArr)->GetEntryPoint();<br />
Param = MI->GetParameters();<br />
MI->Invoke_3 (NULL, Param);<br />
}<br />
catch (_com_error ex)<br />
{<br />
std::wcout<< ex.ErrorMessage();<br />
}<br />
SafeArrayDestroy(psArr);<br />
So if I invoke GUI application all good, but if I invoke Console application Invoke_3() function rise an exceptional situation…
Who has any ideas how to run Console Application?
|
|
|
|