Re: Connecting to sqlexpress from visual c#

Tech-Archive recommends: Speed Up your PC by fixing your registry



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 ***

.



Relevant Pages

  • Re: SQL2K and SQL2005 Beta on one server?
    ... Visual Studio 6 ... Sql Server 2000 Developer Ed (named instance) ... Visual Studio 2005 Beta ...
    (microsoft.public.sqlserver.server)
  • Re: VS.NET 2005 Beta and VS.NET 2003 on the same computer???
    ... Sql Server 2000 Developer Ed (named instance) ... Visual Studio 6 ... Visual Studio 2005 Beta ...
    (microsoft.public.dotnet.languages.vb)
  • Re: newbie: Download Sql Serve CE
    ... Everything you need for SQL Server CE v2.0 ships with VS 2003 for client ... When you do a in VS 2003 with a Smart Device project and ... You will need to download the latest server side bits if you will ...
    (microsoft.public.sqlserver.ce)
  • Smart Devices
    ... Im testing VS2005 and Smart Device application ... I need to connect to SQL server 2005, ... namespace and i cant set refference? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Slow booting xp home.
    ... Changing the boot order to boot first from your hard disk might save you a half second, but you won't be able to boot from a CD until you change it back - and the time spent to do that will erase any previous time saved. ... 2- Consider what software you really want to start with Windows and also how you've configured your applications at startup ... Installing and Registering Visual Studio Express Editions Smart Device ...
    (microsoft.public.windowsxp.perform_maintain)