Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Do you know where/how in Visual Studio VC++ CLR project a specific Data Connection is referred to/stored? I created VC++ CLR project using SQL Server Project template in Wizard and it made me enter database information while creating it. My project is now completed and I was able to use Deploy functionality of VS for the resulting assembly test SQL server auto-deployment.

I'd like to Deploy to prod server now, and I created another Data Connection in VS Server Explorer for it, but I cannot figure out how to make my project to Deploy to the new Data Connection instead of original one I entered at the creation time. There is nothing in project settings it seems that link the project to specific Data Connections, I looked everywhere...

The only thing I was able to find (by text editor view of PinEncryptUDF.vcproj.xxx.xxx.user file) is the following XML group:


<visualstudiouserfile>
ProjectType="Visual C++"
Version="8.00"
ShowAllFiles="false"
>
<sqlclr>
ManagedDbConnection="01…(very long string with hexadecimal numbers)…A13"
ManagedDbProvider="91510608-8809-4020-8897-fba057e22d54"
/>

But I am not sure if that’s where Data Connection reference or connection string itself is stored, and in either case it is not something intended to be edited, I would expect Project Properties to have something.

Please help, I already spent over full day trying to figure this out. Spent a lot of time with Google trying to find the answer, but to no avail. I am aware of being able to deploy the assembly/DLL manually, but wanted to use automated deployment if possible. In case it is important, I am working with VS2005.
Posted
Updated 14-Jun-12 12:03pm
v4

1 solution

I just created a new clr project, and dropped an SqlConnection component on the form. Edited the connection string and void InitializeComponent(void) looks like this:
void InitializeComponent(void)
{
 this->sqlConnection1 = (gcnew System::Data::SqlClient::SqlConnection());
 this->SuspendLayout();
 // 
 // sqlConnection1
 // 
 this->sqlConnection1->ConnectionString = 
    L"Data Source=XXXXXX;Initial Catalog=XXXXXX;Integrated Security=True";
 this->sqlConnection1->FireInfoMessageEventOnUserErrors = false;
 // 
 // Form1
 // 
 this->AutoScaleDimensions = 
     System::Drawing::SizeF(6, 13);
 this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(284, 262);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);

}

You may not be able to see this because of the code folding in visual studio. If this is the case look for small squares containing a '+' on the left side of the editor.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Serbeer 14-Jun-12 19:40pm    
Hm, I do not have anything like it in the code. Perhaps because I use VS2005?
I just created new VC++ CLR SQL Server project, and, as before, it asked me to pick the server to connect to in Add Database Reference dialog. This time it showed both servers I added to Server Explorer, test and prod as options together with button to add a new server.

But after I picked one of the SQL servers and the project was generated, this is mostly empty shell with just

namespace My1 {

public ref class My1Class
{
public:
[Microsoft::SqlServer::Server::SqlProcedure] static void MyStoredProc();
};
}
in main .h file. The only place where there is real content is AssemblyInfo.cpp file. But there is no ConnectionString in it or anywhere in the code. However, when I did binary search through entire directory tree for "ConnectionString", I found it in .ncb and .pch files. Which tells me that it does get compiled in from somewhere at build time. But where is it stored? I am really really confused. I have years of VC++ development experience, but this is my first experience with CLR...
Espen Harlinn 14-Jun-12 20:00pm    
VC++ CLR SQL Server project is for creating stored procedures that executes inside SQL server, so the connection string is implicit.

The code I showed is from a Windows Forms C++ project so it has a connection string.
Serbeer 15-Jun-12 10:46am    
I see. Thanks for trying to help Espen. As I stated in original question, I used SQL Server project template.

That leaves me with the same question: what is the link between specific Data Connection and VC++ CLR SQL Server project and how I can point such project to another Data Connection?
Espen Harlinn 15-Jun-12 10:51am    
Deploy it to the server you want to run it on:
http://msdn.microsoft.com/en-us/library/dahcx0ww(VS.80).aspx

The connection string is usually "context connection=true"

I'm afraid you are mixing the idea of a general .Net C++ application and VC++ CLR Sql Server project.
Serbeer 15-Jun-12 17:29pm    
The link you refer me to says "Select Deploy <project name> from the Build menu" That's what I do now. It then deploys to test server I originally used when creating the project. How can I change it to production server, so that when I select Deploy it deploys to Production server? It does not ask me where to deploy once I "Select Deploy <project name> from the Build menu". It does not give me ability to switch servers in properties of the project. How can I switch the sever to deploy to? It was my original question all along, sigh.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900