SQL SERVER Connection problem VC++

Discussion in '.NET' started by Vigerus, Nov 29, 2009.

  1. Vigerus

    Vigerus

    Joined:
    Nov 29, 2009
    Messages:
    1
    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.
     
    Vigerus, Nov 29, 2009
    #1
    1. Advertising

  2. Vigerus

    ExpertPractice

    Joined:
    Jan 14, 2010
    Messages:
    6
    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
     
    ExpertPractice, Jan 15, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmV6YQ==?=
    Replies:
    3
    Views:
    18,052
    Carlos Barini
    Jun 7, 2004
  2. Daves
    Replies:
    1
    Views:
    408
    tom.pesterDeLeTeTHISSS@pandora.be
    Jun 13, 2005
  3. Joey
    Replies:
    3
    Views:
    4,451
  4. Geoff
    Replies:
    3
    Views:
    474
    Patrick.O.Ige
    Jan 16, 2006
  5. farseer

    SQL Server 2005 + SQL Server Express

    farseer, Aug 7, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    360
    farseer
    Aug 8, 2006
Loading...

Share This Page