SQL Query Language Help RRS feed

  • Question

  • Haiiii everybody,
    can anyone help me. I want to connect from my form to database using sql query
    but there is a lot of problem and i been trying hard but still none of it works.

    This is the code that im been working but there still error:

     Dim FoodDataSource As New SqlConnection
     FoodDataSource.ConnectionString = ConfugurationManager.(RMS.My.MySettings.DBRMSConnectionString).ToString

    Maybe One of u have any suggestion or maybe there is a better code that im using now
    Im uSing VB2005 and sql server 2005

    Thank U
    Sunday, September 30, 2007 8:11 AM

All replies

  • I try to answer your question although there are not enough details here (can you provide details about your configuration file, the error(s) you are getting?)

    Here is an example of an APP,CONFIG file content (the connection strings part of it).


    Code Block


    <add name="myConnStr" connectionString="Database=MyDataBase;Server=(local)\SQLEXPRESS;Integrated Security=SSPI"

    providerName="System.Data.SqlClient" />

    </< FONT>connectionStrings>



    Then in your code add:


    Code Block

    String connStr = System.Configuration.ConfigurationManager.ConnectionStrings["myConnStr"].ConnectionString;

    SqlConnection cn = new SqlConnection(connStr);



    You must add a reference to System.Configuration and System.Data assemblies to your project.





    Sunday, September 30, 2007 10:10 AM
  • What exact issue do you have here? You did not post your question and did not describe what the actual issue is.


    Sunday, September 30, 2007 12:40 PM