API/CodeSamples/SqlServerConnectionString.md
... ...
@@ -45,4 +45,28 @@ Public Class CustomAdHocConfig
45 45
End Sub
46 46
47 47
End Class
48
-```
... ...
\ No newline at end of file
0
+```
1
+
2
+##Specifying Username and password
3
+
4
+There are certain patterns that are recognized as settings within the connection string itself. The username and password are among them. You can read more about the parts of the SQL connection string [[here|http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx]]. Here are the essential parts of the connection string:
5
+
6
+* **server** - The name or network address of the instance of SQL Server to which to connect. The port number can be specified after the server name: ``server=tcp:servername, portnumber``. When specifying a local instance, always use (local). To force a protocol, add one of the following prefixes: np:(local), tcp:(local), lpc:(local).
7
+* **Database** - the name of the database you want to connect to
8
+* **User ID** - The username that you're logging in as (Not recommended, but still popular). It is recommended to use Trusted_Connection instead.
9
+* **Password** - The password you're using to log into the database (Not recommended, but still popular). It is recommended to use Trusted_Connection instead.
10
+* **Trusted_Connection** - When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication.
11
+Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true. See the above article for more information.
12
+
13
+Then you simply have to insert the values you need into the connection string
14
+
15
+```csharp
16
+public static void InitializeReporting()
17
+{
18
+ String uname = HttpContext.Current.Session["UserName"];
19
+ String pw = HttpContext.Current.Session["Password"]; //unsecure. Use at your own risk. There are many great articles about how to handle usernames and passwords and perhaps your organization already uses one.
20
+
21
+ Izenda.AdHoc.AdHocSettings.SqlServerConnectionString =
22
+ "server=zag.izenda.com;Database=Northwind;User ID="+ uname +
23
+ ";Password=" + pw + ";Trusted_Connection=False";
24
+}
... ...
\ No newline at end of file