Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If it's a resource file like so:</p> <p><code>private static readonly string connString = Resource1.connString;</code></p> <p>Where connString is the name of the key. If it is a <code>web.config</code> file</p> <p>Something like so:</p> <p><code>private static readonly string connString = System.Configuration.ConfigurationManager.AppSettings["strConn"];</code> where conn is defined in your web config file.</p> <pre><code>&lt;add key="strConn" value="User ID=test;Password=test;Initial Catalog=TestDB;Data Source=NameOfServer;"/&gt; </code></pre> <p>Then call the sproc:</p> <pre><code> //connString = the string of our database app found in the resource file using (SqlConnection con = new SqlConnection(connString)) { using (SqlCommand cmd = new SqlCommand("EMPDLL_selClientByClientID", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ClientID", SqlDbType.VarChar).Value = cID; con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { if (reader.Read()) { //more code } } } } } </code></pre> <p>That's if you are coding in C#, VB.net its the same deal just a bit more wordier :), here's a small sample:</p> <pre><code> Public Sub DeleteEmployee(ByVal lVID As Long) Dim conMyData As SqlConnection Dim cmdDelete As SqlCommand Try conMyData = New SqlConnection(connString) cmdDelete = New SqlCommand("delEmployee", conMyData) With cmdDelete .CommandType = CommandType.StoredProcedure 'add the parameters .Parameters.Add("@LoginID", SqlDbType.BigInt).Value = lVID 'the request conMyData.Open() 'open a connection .ExecuteNonQuery() 'execute it End With Catch ex As Exception Throw ex Finally cmdDelete = Nothing conMyData.Close() conMyData = Nothing End Try End Sub </code></pre> <p>Of course you should use a <code>using</code> statement instead of <code>try/catch/finally</code> to ensure you clean up your resources that are being used.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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