Solved

C# not reading backslash in my datasource...please help!

Posted on 2004-08-18
5
343 Views
Last Modified: 2010-04-15
Hello All

I'm having an issue trying to connect my sql databse from my c# app. It's not allowing me to write out my datasource which is DEAN\NETSDK. For some reason it isn't accepting the backslash in the datasource. How do I fix. Thanks

Dean
0
Comment
Question by:dean3740
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
s_sansanwal earned 125 total points
ID: 11837968
try using  DEAN\\NETSDK
or update what is the exact error coming

Cheers
S Sansanwal
0
 

Author Comment

by:dean3740
ID: 11838019
would I need to put quotes around \\? because in vs.net 2003 i'm getting a red underline beneath it.
0
 

Author Comment

by:dean3740
ID: 11838123
Mr. S Sansanwal

Here is my line of code that creates the string i need to access my sql server.

 con= new SqlConnection( "@"  +"Data Source="+FormConfig.DataSource
                          + "\\"
                          +FormConfig.Instance
                          +";Initial Catalog="+FormConfig.InitialCatalog
                          +";Integrated Security ="+FormConfig.IntegratedSecurity);


For some reason its not working, and I'm getting a keyword not supported '@data source' error. What could be the problem?
0
 
LVL 9

Expert Comment

by:s_sansanwal
ID: 11838142
do
 
con= new SqlConnection( @"Data Source="+FormConfig.DataSource
                        + "\\"
                        +FormConfig.Instance
                        +";Initial Catalog="+FormConfig.InitialCatalog
                        +";Integrated Security ="+FormConfig.IntegratedSecurity);

u don't need to have double quotes around @

Cheers,
S Sansanwal
0
 

Author Comment

by:dean3740
ID: 11838174
That worked great. Thanks again.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp web application 3 35
Why use this lambda? 12 60
I need help adding validation to my MVC.Net view 6 21
Trigger C# code inside the SQL Server 6 25
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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