1 Replies - 168 Views - Last Post: 29 November 2013 - 12:02 AM Rate Topic: -----

#1 Vault-Boy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 18-May 13

Local Database error, needing assistance. [Too long error...]

Posted 28 November 2013 - 10:27 PM

The error was:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)



I got that on this class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using System.Data.SqlTypes;
using Wishlist.Properties;
using System.Windows.Forms;
using Db4objects;

namespace Wishlist
{
    class databaseupdate
    {
        public static Boolean e = false;
        public static int count = 0;

        public static void Update() { 
         
        }

        public static void Insert(string name, string desc, string price, string user, Uri website)
        {
            count = Form1.x;
            SqlConnection c = new SqlConnection(Properties.Settings.Default.itemsConnectionString.ToString());
            c.Open();
            c.ChangeDatabase(Properties.Settings.Default.itemsConnectionString);
            c.Database.Insert(0, name);
        }

    }
}




I have a database called items. The itemsConnectionString is set to:
Data Source=|DataDirectory|\items.sdf


Do you guys have any solutions?

Is This A Good Question/Topic? 0
  • +

Replies To: Local Database error, needing assistance. [Too long error...]

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3160
  • View blog
  • Posts: 9,532
  • Joined: 05-May 12

Re: Local Database error, needing assistance. [Too long error...]

Posted 29 November 2013 - 12:02 AM

On line 27, you need to use SqlCeConnection, not SqlConnection.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1