SQL SERVER Connection problem VC++

Joined
Nov 29, 2009
Messages
1
Reaction score
0
Can anyone help me with this?

public:

String^ name;
String^ cstr;
TreeNode^ tn;
SqlCommand sc;
String^ procedura;
SqlConnection^ cn;
SqlConnectionStringBuilder^ sqb;

private: System::Void STRUKTURA_Load(System::Object^ sender, System::EventArgs^ e)

{

//sqb = gcnew SqlConnectionStringBuilder();
//sqb->DataSource = "ROOT\FENIKS";
//sqb->InitialCatalog = "RC";
//sqb->IntegratedSecurity = true;
cn = gcnew SqlConnection();
cstr = "Data Source=ROOT\FENIKS;Initial Catalog=RC;Integrated Security=True; IsAppSettingsProperty=False; Modifier=Assembly; Name=root\feniks.RC.dbo; ParameterPrefix=@; Provider=System.Data.SqlClient;";
cn->ConnectionString = cstr;
cn->Open();

//cn= gcnew SqlConnection("Data Source=ROOT\FENIKS;Initial Catalog=RC;Integrated Security=True; IsAppSettingsProperty=False; Modifier=Assembly; Name=root\feniks.RC.dbo; ParameterPrefix=@; Provider=System.Data.SqlClient;");
//cn->Open();


}


private: System::Void bt1_Click(System::Object^ sender, System::EventArgs^ e)
{

name = ID_S->Text;
tn = gcnew TreeNode;
tree->Nodes->Add(name);
procedura = "INSERT INTO [RC].[dbo].([IDS])VALUES(<IDS, "+name+",>)";
::DialogResult result = MessageBox::Show(this,procedura,"Błąd wprowadzanych danych",
MessageBoxButtons::OK,
MessageBoxIcon::Error);
SqlCommand^ con1 = gcnew SqlCommand(procedura,cn);
cn->Open();
con1->ExecuteNonQuery();
cn->Close();




}

AND ERROR THAT APPEARS:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll

Additional information: The ConnectionString property has not been initialized.
 
Joined
Jan 14, 2010
Messages
6
Reaction score
0
Actually i am not a C++ guy but can you confirm you are using the right connection string.

Link: connectionstrings.com
its one of the best source to get all types of connection strings.

i hope this will help

@li
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top