Solved

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

Posted on 2003-12-01
2
211 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now