Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Form Application and SQL Server
    text
    copied!<p><strong>UPDATE 2</strong></p> <p>I fixed the error by adding <code>System.Configuration</code> to the reference file. I had already added it to my class with <code>using System.Configuration;</code><br> I found the answer here: <a href="https://stackoverflow.com/questions/1274852/the-name-configurationmanager-does-not-exist-in-the-current-context/1836938#comment18074599_1836938">The name 'ConfigurationManager' does not exist in the current context</a></p> <p>Any further issues will be addressed in a new question.</p> <p><strong>Original(ish) Post</strong></p> <p>I have Microsoft SQL Server Management Studio. In the studio I created a database called <code>Logbook</code> that exists locally on my computer. </p> <p>I have also created a user interface using a Windows forms application in VS C# Express. I would like to connect it to my logbook database in order to update, select, delete, and insert entries into the database through the UI.</p> <p>However, I cannot figure out how connect the two. I have played around with the "Add new data source" wizard to no avail. I also cannot find anything helpful in the MSDN or other tutorials online. </p> <p><strong>UPDATE</strong></p> <p>I created a new database and project to work with until I figure out how to properly do this so I don't accidently break anything in my project.<br> The Schema is:</p> <pre><code>Student(sid: int, fname: char(10), lname: char(10), age:int, major:char(10)) Course(cid:int, desc:char(50), dept:char(10)) Enrolled(sid:int, cid:int, quarter:char(10), grade:char(10)) </code></pre> <p>Here is the connection string generated by the "Add Data Source" wizard</p> <pre><code>&lt;add name="boathouseLogConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&amp;quot;C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\boathouseLog.mdf&amp;quot;;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" /&gt; </code></pre> <p>I have successfully gotten my database into the project. However, when I try running a stored procedure I get this error <code>Argument Exception was unhandled. Format of the initialization string does not conform to specification starting at index 0.</code></p> <p>The error occurs on line 2. </p> <pre><code> DataTable dt = new DataTable(); SqlConnection sqlConn = new SqlConnection(selectedConnectionString); SqlCommand myCommand = new SqlCommand("proc_getMember", sqlConn); myCommand.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(myCommand); </code></pre> <p>the <code>selectedConnectionString</code> variable is set to <code>boathouseLogConnectionString</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload