C#-App : COnnection to SQL Server 2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • angelajocelyn
    New Member
    • Jul 2008
    • 1

    #1

    C#-App : COnnection to SQL Server 2005

    hello....i need your help. i got an assignment about prediction in data mining. and the problem is, i'm new in C# and data mining. i've tried to search an example in sql server site but when i try it into my project it wont worked. an sql exception was made. here is some part of the code :
    using System;
    using Microsoft.Analy sisServices;
    using System.Data;
    using System.Data.Com mon;
    using System.Data.Ole Db;

    namespace AMOSampleForDM
    {
    public Database CreateDatabase( Server srv, string databaseName)
    {
    Database dbNew = new Database(databa seName, Utils.GetSyntac ticallyValidID( databaseName, typeof(Database ))) ;

    if (srv.Databases. ContainsName(da tabaseName))
    srv.Databases.R emoveAt(srv.Dat abases.IndexOfN ame(databaseNam e));


    srv.Databases.A dd(dbNew);
    dbNew.Update(tr ue);

    return dbNew;
    }
    [STAThread]
    static void Main(string[] args)
    {

    try
    {
    Server srv = new Server();

    srv.Connect("lo calhost");

    Database db = CreateDatabase( srv, "Test");
    }
    catch (Exception e)
    {
    Console.WriteLi ne(e.Message);
    }

    and the exception is "make sure that the "sql browser" is running. cannot made a connection because the target machine is actively refused it." i really confused, because i'm make sure that the sql browser and server are running.
    could anyone help me with this problem or would you give me another example about data mining in C#???? please i really need your help...

    thanks a lot,

    angela
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    If localhost is your connection string then you haven't supplied a proper connection. You normally have to give other details and credentials. HTH.

    Comment

    Working...