Solved

My SQL server has a '\' and this reeks havoc on my C# program...

Posted on 2003-12-01
2
218 Views
Last Modified: 2012-05-04
I get an error when I run this...how do I fool C# to ignore my '\' in the SQLconnection conn = statement...

thanks

<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

    private void Page_Load(object sender, System.EventArgs e)
    {
    if (!IsPostBack)
    {
    string name = System.Web.HttpUtility.UrlDecode(Request.QueryString["sqlstring"]);

    SqlConnection conn = new SqlConnection ("server=WWIIS\SQLSERVER;database=data1;uid=joe;pwd=nz6j");


0
Comment
Question by:programmerexchange
2 Comments
 
LVL 12

Accepted Solution

by:
vascov earned 250 total points
ID: 9852780
2 options:
    SqlConnection conn = new SqlConnection ( @"server=WWIIS\SQLSERVER;database=data1;uid=joe;pwd=nz6j");

or

    SqlConnection conn = new SqlConnection ("server=WWIIS\\SQLSERVER;database=data1;uid=joe;pwd=nz6j");

HTH




0
 

Author Comment

by:programmerexchange
ID: 9855724
It was that \\...thanks for the help...was making me crazy and I couldn't find it anywhere...

dk
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Angular JS Route 3 68
Connection String 16 54
Webform example, External Authentication Services, OAUTH, asp.net 4.6.2 1 29
How useful is the free version of Selenium? 3 31
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question