Re: Connecting to sqlexpress from visual c#
- From: "Ginny Caughey MVP" <ginny.caughey.online@xxxxxxxxxxxxxx>
- Date: Mon, 12 Jan 2009 13:41:53 -0500
Yemi,
To connect a smart device to SQL Server or Express, you need to provide the IP address and port rather than a named instance, and even though you are using integrated security, you still need to provide the domain\userID and password.
By the way, this newsgroup is for SQL Server Compact, not SQL Server/Express.
--
Ginny Caughey
Device Application Development MVP
"Yemi Awe" <dawe@xxxxxxxxx> wrote in message news:%235iRUPOdJHA.920@xxxxxxxxxxxxxxxxxxxxxxx
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 ***
.
- References:
- Connecting to sqlexpress from visual c#
- From: Yemi Awe
- Connecting to sqlexpress from visual c#
- Prev by Date: Connecting to sqlexpress from visual c#
- Next by Date: Re: SQLCE 3.0 losing data after transaction
- Previous by thread: Connecting to sqlexpress from visual c#
- Index(es):
Relevant Pages
|