Connecting to a SQL Server 2012 database in Visual Studio 2008












0















I am currently developing a mobile application based on Windows CE for my team to track out assets and store them in our existing database.



I am able to develop and deploy the software successfully however I can't seem to connect to my SQL Server 2012 database from Visual Studio 2008. When I try to connect from Visual Studio 2017, it works just fine.



This is my test code only not my real asset tracker code so it wont have the UI I built for the asset tracker app.



using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace test_smart_device
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button1.Click += new EventHandler(button_connect);
}

private void button_connect(object sender, EventArgs e)
{
string connetionString = null;
SqlConnection cnn ;
connetionString = "Data Source=172.16.206.20;Initial Catalog=IBusinessTest;Integrated Security=SSPI;User ID=username;Password=123456";

cnn = new SqlConnection(connetionString);

try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
}
}


When I try to connect to my database, I get this error:



error details captured by the debugger



This is from the debugger when I put the breakpoint at the catch statement










share|improve this question

























  • if you run this on the actual Windows CE device, what happens?

    – Minijack
    Nov 28 '18 at 4:05











  • I TRIED THIS and removed Integrated Security=SSPI; from the connection string as pcdev suggested from my connection string and it works! However in the emulator it didn't work I think my laptop is connected to a different WLAN as per my device. Will investigate this more and update in my answer.

    – user3308595
    Nov 28 '18 at 5:54


















0















I am currently developing a mobile application based on Windows CE for my team to track out assets and store them in our existing database.



I am able to develop and deploy the software successfully however I can't seem to connect to my SQL Server 2012 database from Visual Studio 2008. When I try to connect from Visual Studio 2017, it works just fine.



This is my test code only not my real asset tracker code so it wont have the UI I built for the asset tracker app.



using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace test_smart_device
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button1.Click += new EventHandler(button_connect);
}

private void button_connect(object sender, EventArgs e)
{
string connetionString = null;
SqlConnection cnn ;
connetionString = "Data Source=172.16.206.20;Initial Catalog=IBusinessTest;Integrated Security=SSPI;User ID=username;Password=123456";

cnn = new SqlConnection(connetionString);

try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
}
}


When I try to connect to my database, I get this error:



error details captured by the debugger



This is from the debugger when I put the breakpoint at the catch statement










share|improve this question

























  • if you run this on the actual Windows CE device, what happens?

    – Minijack
    Nov 28 '18 at 4:05











  • I TRIED THIS and removed Integrated Security=SSPI; from the connection string as pcdev suggested from my connection string and it works! However in the emulator it didn't work I think my laptop is connected to a different WLAN as per my device. Will investigate this more and update in my answer.

    – user3308595
    Nov 28 '18 at 5:54
















0












0








0


1






I am currently developing a mobile application based on Windows CE for my team to track out assets and store them in our existing database.



I am able to develop and deploy the software successfully however I can't seem to connect to my SQL Server 2012 database from Visual Studio 2008. When I try to connect from Visual Studio 2017, it works just fine.



This is my test code only not my real asset tracker code so it wont have the UI I built for the asset tracker app.



using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace test_smart_device
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button1.Click += new EventHandler(button_connect);
}

private void button_connect(object sender, EventArgs e)
{
string connetionString = null;
SqlConnection cnn ;
connetionString = "Data Source=172.16.206.20;Initial Catalog=IBusinessTest;Integrated Security=SSPI;User ID=username;Password=123456";

cnn = new SqlConnection(connetionString);

try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
}
}


When I try to connect to my database, I get this error:



error details captured by the debugger



This is from the debugger when I put the breakpoint at the catch statement










share|improve this question
















I am currently developing a mobile application based on Windows CE for my team to track out assets and store them in our existing database.



I am able to develop and deploy the software successfully however I can't seem to connect to my SQL Server 2012 database from Visual Studio 2008. When I try to connect from Visual Studio 2017, it works just fine.



This is my test code only not my real asset tracker code so it wont have the UI I built for the asset tracker app.



using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace test_smart_device
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button1.Click += new EventHandler(button_connect);
}

private void button_connect(object sender, EventArgs e)
{
string connetionString = null;
SqlConnection cnn ;
connetionString = "Data Source=172.16.206.20;Initial Catalog=IBusinessTest;Integrated Security=SSPI;User ID=username;Password=123456";

cnn = new SqlConnection(connetionString);

try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
}
}


When I try to connect to my database, I get this error:



error details captured by the debugger



This is from the debugger when I put the breakpoint at the catch statement







c# visual-studio-2008 visual-studio-2008-sp1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 5:42









marc_s

581k13011211268




581k13011211268










asked Nov 28 '18 at 4:00









user3308595user3308595

206




206













  • if you run this on the actual Windows CE device, what happens?

    – Minijack
    Nov 28 '18 at 4:05











  • I TRIED THIS and removed Integrated Security=SSPI; from the connection string as pcdev suggested from my connection string and it works! However in the emulator it didn't work I think my laptop is connected to a different WLAN as per my device. Will investigate this more and update in my answer.

    – user3308595
    Nov 28 '18 at 5:54





















  • if you run this on the actual Windows CE device, what happens?

    – Minijack
    Nov 28 '18 at 4:05











  • I TRIED THIS and removed Integrated Security=SSPI; from the connection string as pcdev suggested from my connection string and it works! However in the emulator it didn't work I think my laptop is connected to a different WLAN as per my device. Will investigate this more and update in my answer.

    – user3308595
    Nov 28 '18 at 5:54



















if you run this on the actual Windows CE device, what happens?

– Minijack
Nov 28 '18 at 4:05





if you run this on the actual Windows CE device, what happens?

– Minijack
Nov 28 '18 at 4:05













I TRIED THIS and removed Integrated Security=SSPI; from the connection string as pcdev suggested from my connection string and it works! However in the emulator it didn't work I think my laptop is connected to a different WLAN as per my device. Will investigate this more and update in my answer.

– user3308595
Nov 28 '18 at 5:54







I TRIED THIS and removed Integrated Security=SSPI; from the connection string as pcdev suggested from my connection string and it works! However in the emulator it didn't work I think my laptop is connected to a different WLAN as per my device. Will investigate this more and update in my answer.

– user3308595
Nov 28 '18 at 5:54














1 Answer
1






active

oldest

votes


















0














Two things stick out to me:




  • You connection string includes Integrated Security=SSPI;, but you also include User ID=username;Password=123456 - so which is it, are you using Integrated Security (ie. logging in with the Windows user that the program is running as - domain or identical workgroup credentials on both the CE device and SQL Server), or are you trying to use SQL Server auth (by specifying a user ID and password)? You can't use both.

  • The error SQL Server does not exist or access denied implies that your connection was rejected, but doesn't say why. If it's not credentials then it could be the connection itself. Have you checked that the server is remotely accessible from the device? Are they on the same local network? If using a physical device on WiFi, does it have permission to communicate with other devices on the network (some WiFi routers, especially corporate ones, have the option of only allowing traffic to the gateway, and rejecting requests to local addresses).






share|improve this answer
























  • Hi I used the same connection string and library in my visual studio 2017 works just fine. The reason I added Integrated Security=SSPI; is because I tried without it and it doesn't work. This has lead me to believe that something is wrong with my Visual studio 2008.

    – user3308595
    Nov 28 '18 at 5:45













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53511919%2fconnecting-to-a-sql-server-2012-database-in-visual-studio-2008%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Two things stick out to me:




  • You connection string includes Integrated Security=SSPI;, but you also include User ID=username;Password=123456 - so which is it, are you using Integrated Security (ie. logging in with the Windows user that the program is running as - domain or identical workgroup credentials on both the CE device and SQL Server), or are you trying to use SQL Server auth (by specifying a user ID and password)? You can't use both.

  • The error SQL Server does not exist or access denied implies that your connection was rejected, but doesn't say why. If it's not credentials then it could be the connection itself. Have you checked that the server is remotely accessible from the device? Are they on the same local network? If using a physical device on WiFi, does it have permission to communicate with other devices on the network (some WiFi routers, especially corporate ones, have the option of only allowing traffic to the gateway, and rejecting requests to local addresses).






share|improve this answer
























  • Hi I used the same connection string and library in my visual studio 2017 works just fine. The reason I added Integrated Security=SSPI; is because I tried without it and it doesn't work. This has lead me to believe that something is wrong with my Visual studio 2008.

    – user3308595
    Nov 28 '18 at 5:45


















0














Two things stick out to me:




  • You connection string includes Integrated Security=SSPI;, but you also include User ID=username;Password=123456 - so which is it, are you using Integrated Security (ie. logging in with the Windows user that the program is running as - domain or identical workgroup credentials on both the CE device and SQL Server), or are you trying to use SQL Server auth (by specifying a user ID and password)? You can't use both.

  • The error SQL Server does not exist or access denied implies that your connection was rejected, but doesn't say why. If it's not credentials then it could be the connection itself. Have you checked that the server is remotely accessible from the device? Are they on the same local network? If using a physical device on WiFi, does it have permission to communicate with other devices on the network (some WiFi routers, especially corporate ones, have the option of only allowing traffic to the gateway, and rejecting requests to local addresses).






share|improve this answer
























  • Hi I used the same connection string and library in my visual studio 2017 works just fine. The reason I added Integrated Security=SSPI; is because I tried without it and it doesn't work. This has lead me to believe that something is wrong with my Visual studio 2008.

    – user3308595
    Nov 28 '18 at 5:45
















0












0








0







Two things stick out to me:




  • You connection string includes Integrated Security=SSPI;, but you also include User ID=username;Password=123456 - so which is it, are you using Integrated Security (ie. logging in with the Windows user that the program is running as - domain or identical workgroup credentials on both the CE device and SQL Server), or are you trying to use SQL Server auth (by specifying a user ID and password)? You can't use both.

  • The error SQL Server does not exist or access denied implies that your connection was rejected, but doesn't say why. If it's not credentials then it could be the connection itself. Have you checked that the server is remotely accessible from the device? Are they on the same local network? If using a physical device on WiFi, does it have permission to communicate with other devices on the network (some WiFi routers, especially corporate ones, have the option of only allowing traffic to the gateway, and rejecting requests to local addresses).






share|improve this answer













Two things stick out to me:




  • You connection string includes Integrated Security=SSPI;, but you also include User ID=username;Password=123456 - so which is it, are you using Integrated Security (ie. logging in with the Windows user that the program is running as - domain or identical workgroup credentials on both the CE device and SQL Server), or are you trying to use SQL Server auth (by specifying a user ID and password)? You can't use both.

  • The error SQL Server does not exist or access denied implies that your connection was rejected, but doesn't say why. If it's not credentials then it could be the connection itself. Have you checked that the server is remotely accessible from the device? Are they on the same local network? If using a physical device on WiFi, does it have permission to communicate with other devices on the network (some WiFi routers, especially corporate ones, have the option of only allowing traffic to the gateway, and rejecting requests to local addresses).







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '18 at 4:35









pcdevpcdev

1,41711028




1,41711028













  • Hi I used the same connection string and library in my visual studio 2017 works just fine. The reason I added Integrated Security=SSPI; is because I tried without it and it doesn't work. This has lead me to believe that something is wrong with my Visual studio 2008.

    – user3308595
    Nov 28 '18 at 5:45





















  • Hi I used the same connection string and library in my visual studio 2017 works just fine. The reason I added Integrated Security=SSPI; is because I tried without it and it doesn't work. This has lead me to believe that something is wrong with my Visual studio 2008.

    – user3308595
    Nov 28 '18 at 5:45



















Hi I used the same connection string and library in my visual studio 2017 works just fine. The reason I added Integrated Security=SSPI; is because I tried without it and it doesn't work. This has lead me to believe that something is wrong with my Visual studio 2008.

– user3308595
Nov 28 '18 at 5:45







Hi I used the same connection string and library in my visual studio 2017 works just fine. The reason I added Integrated Security=SSPI; is because I tried without it and it doesn't work. This has lead me to believe that something is wrong with my Visual studio 2008.

– user3308595
Nov 28 '18 at 5:45






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53511919%2fconnecting-to-a-sql-server-2012-database-in-visual-studio-2008%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)