Connecting to sqlexpress from visual c#
- From: Yemi Awe <dawe@xxxxxxxxx>
- Date: Mon, 12 Jan 2009 10:30:20 -0800
I am almost getting frustrated please help me.
I need to establish a connection to the sqlexpress on my system from my
visual c#. I am programming a smart device using visual studio 2005.
I did the following
I enabled remote connections from the surface area config for tcp and
named pipes
I started the browser
I could connect from MS visual studio
The server is up and running
but when i tried to connect from visual studio using the code
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using System.Data;
namespace mQAQI
{
class sqlDatabaseUtil
{
SqlConnection dataConnection = new SqlConnection();
public void getConnection()
{
try
{
String connString = "Data
Source=abudawe\\sqlexpress;Initial Catalog=mQAQI;Integrated
Security=True";
//String connString = "Data Source=xx.sdf";
dataConnection.ConnectionString = connString;
dataConnection.Open();
MessageBox.Show("Connected to database successfully.");
}
catch (FileNotFoundException fe)
{
MessageBox.Show(fe.StackTrace + "Error Accessing the
database.");
MessageBox.Show(fe.Message);
}
catch (SqlException sqle)
{
MessageBox.Show(sqle.StackTrace + "Error Accessing the
database.");
MessageBox.Show(sqle.Message);
}
catch (IOException io)
{
MessageBox.Show(io.StackTrace + "Error Accessing the
database.");
MessageBox.Show(io.Message);
}
/* catch (Exception e)
{
MessageBox.Show(e.StackTrace + "Error Accessing the
database.");
Console.WriteLine(e.StackTrace);
}*/
finally
{
dataConnection.Close();
}
}
}
}
I get the following message
"specified server not found: abudawe\sqlexpress"
Please what am i doing wrong. I have battled with this issue for the
past 4 days
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
.
- Follow-Ups:
- Re: Connecting to sqlexpress from visual c#
- From: Ginny Caughey MVP
- Re: Connecting to sqlexpress from visual c#
- Prev by Date: Re: SQL CE Synchronising Problems
- Next by Date: Re: Connecting to sqlexpress from visual c#
- Previous by thread: SQLCE 3.0 losing data after transaction
- Next by thread: Re: Connecting to sqlexpress from visual c#
- Index(es):
Relevant Pages
|