how to connect to a database which is located in a local server in C#
I need to access my database which is located in University central server. University gave me the ip address and also root access and the password. I don't Have the port address,i know to connect to a database with port address like this,i Used this Connection String to connect multiple computers and it works,but Want to connect my database through the univercity server
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
University server is using => linux , Cenos
My software is Running on => Windows
Mysql Server is => phpMyAdmin
Server ip is =>10.10.10.XX
username=>root
password=>XXXXX
this is my Connection String in C#
this is the error what i get
public string datastring = ("Server=10.10.10.XX;Database=tmsdatabase;Uid=root;Pwd=XXXXX;");
What i'm Asking is to solution to my Error............
Thank you..........
OK i open the connection and nothing changed
c# mysql windows networking
add a comment |
I need to access my database which is located in University central server. University gave me the ip address and also root access and the password. I don't Have the port address,i know to connect to a database with port address like this,i Used this Connection String to connect multiple computers and it works,but Want to connect my database through the univercity server
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
University server is using => linux , Cenos
My software is Running on => Windows
Mysql Server is => phpMyAdmin
Server ip is =>10.10.10.XX
username=>root
password=>XXXXX
this is my Connection String in C#
this is the error what i get
public string datastring = ("Server=10.10.10.XX;Database=tmsdatabase;Uid=root;Pwd=XXXXX;");
What i'm Asking is to solution to my Error............
Thank you..........
OK i open the connection and nothing changed
c# mysql windows networking
con.open() before da.fill()
– Ravi
Nov 26 '18 at 7:05
Just making sure here, 10.x.x.x is internal IP, so your computer is connected to university network/VPN, right? Also, can you ping the IP from your computer console?
– Martheen
Nov 26 '18 at 7:54
yes i can access and also i can access the database from phpmyadmin using the given ip ,username,password ,i created the database inside the server using phpmyadmin by myself
– Kãvîñdū Tîssêrã
Nov 26 '18 at 8:15
add a comment |
I need to access my database which is located in University central server. University gave me the ip address and also root access and the password. I don't Have the port address,i know to connect to a database with port address like this,i Used this Connection String to connect multiple computers and it works,but Want to connect my database through the univercity server
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
University server is using => linux , Cenos
My software is Running on => Windows
Mysql Server is => phpMyAdmin
Server ip is =>10.10.10.XX
username=>root
password=>XXXXX
this is my Connection String in C#
this is the error what i get
public string datastring = ("Server=10.10.10.XX;Database=tmsdatabase;Uid=root;Pwd=XXXXX;");
What i'm Asking is to solution to my Error............
Thank you..........
OK i open the connection and nothing changed
c# mysql windows networking
I need to access my database which is located in University central server. University gave me the ip address and also root access and the password. I don't Have the port address,i know to connect to a database with port address like this,i Used this Connection String to connect multiple computers and it works,but Want to connect my database through the univercity server
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
University server is using => linux , Cenos
My software is Running on => Windows
Mysql Server is => phpMyAdmin
Server ip is =>10.10.10.XX
username=>root
password=>XXXXX
this is my Connection String in C#
this is the error what i get
public string datastring = ("Server=10.10.10.XX;Database=tmsdatabase;Uid=root;Pwd=XXXXX;");
What i'm Asking is to solution to my Error............
Thank you..........
OK i open the connection and nothing changed
c# mysql windows networking
c# mysql windows networking
edited Nov 26 '18 at 7:12
Kãvîñdū Tîssêrã
asked Nov 26 '18 at 6:43
Kãvîñdū TîssêrãKãvîñdū Tîssêrã
85
85
con.open() before da.fill()
– Ravi
Nov 26 '18 at 7:05
Just making sure here, 10.x.x.x is internal IP, so your computer is connected to university network/VPN, right? Also, can you ping the IP from your computer console?
– Martheen
Nov 26 '18 at 7:54
yes i can access and also i can access the database from phpmyadmin using the given ip ,username,password ,i created the database inside the server using phpmyadmin by myself
– Kãvîñdū Tîssêrã
Nov 26 '18 at 8:15
add a comment |
con.open() before da.fill()
– Ravi
Nov 26 '18 at 7:05
Just making sure here, 10.x.x.x is internal IP, so your computer is connected to university network/VPN, right? Also, can you ping the IP from your computer console?
– Martheen
Nov 26 '18 at 7:54
yes i can access and also i can access the database from phpmyadmin using the given ip ,username,password ,i created the database inside the server using phpmyadmin by myself
– Kãvîñdū Tîssêrã
Nov 26 '18 at 8:15
con.open() before da.fill()
– Ravi
Nov 26 '18 at 7:05
con.open() before da.fill()
– Ravi
Nov 26 '18 at 7:05
Just making sure here, 10.x.x.x is internal IP, so your computer is connected to university network/VPN, right? Also, can you ping the IP from your computer console?
– Martheen
Nov 26 '18 at 7:54
Just making sure here, 10.x.x.x is internal IP, so your computer is connected to university network/VPN, right? Also, can you ping the IP from your computer console?
– Martheen
Nov 26 '18 at 7:54
yes i can access and also i can access the database from phpmyadmin using the given ip ,username,password ,i created the database inside the server using phpmyadmin by myself
– Kãvîñdū Tîssêrã
Nov 26 '18 at 8:15
yes i can access and also i can access the database from phpmyadmin using the given ip ,username,password ,i created the database inside the server using phpmyadmin by myself
– Kãvîñdū Tîssêrã
Nov 26 '18 at 8:15
add a comment |
1 Answer
1
active
oldest
votes
You didn open the connection.
You have to use con.Open();
so you can establish the connection to the database.
and you have to close the connection as well after you finish your readings with con.Close()
.
Also you have to put everything in try catch block so your code should be
MySqlConnection con = new MySqlConnection(dataString);
try
{
con.Open();
(rest of your code)
con.Close()
}
catch
{
(something went wrong)
con.Close();
}
EDIT: I don't know if in your connection string you put the port as well. In your first code you have
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
That's the correct format of a connection string.
error is not about the open connection ,it is about unable to connect to the mysql host ,real problem is server and the software is not calling to each other because server is running on linux and my software is running on windows thats the problem
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:06
i need to make them talk
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:07
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475933%2fhow-to-connect-to-a-database-which-is-located-in-a-local-server-in-c-sharp%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
You didn open the connection.
You have to use con.Open();
so you can establish the connection to the database.
and you have to close the connection as well after you finish your readings with con.Close()
.
Also you have to put everything in try catch block so your code should be
MySqlConnection con = new MySqlConnection(dataString);
try
{
con.Open();
(rest of your code)
con.Close()
}
catch
{
(something went wrong)
con.Close();
}
EDIT: I don't know if in your connection string you put the port as well. In your first code you have
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
That's the correct format of a connection string.
error is not about the open connection ,it is about unable to connect to the mysql host ,real problem is server and the software is not calling to each other because server is running on linux and my software is running on windows thats the problem
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:06
i need to make them talk
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:07
add a comment |
You didn open the connection.
You have to use con.Open();
so you can establish the connection to the database.
and you have to close the connection as well after you finish your readings with con.Close()
.
Also you have to put everything in try catch block so your code should be
MySqlConnection con = new MySqlConnection(dataString);
try
{
con.Open();
(rest of your code)
con.Close()
}
catch
{
(something went wrong)
con.Close();
}
EDIT: I don't know if in your connection string you put the port as well. In your first code you have
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
That's the correct format of a connection string.
error is not about the open connection ,it is about unable to connect to the mysql host ,real problem is server and the software is not calling to each other because server is running on linux and my software is running on windows thats the problem
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:06
i need to make them talk
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:07
add a comment |
You didn open the connection.
You have to use con.Open();
so you can establish the connection to the database.
and you have to close the connection as well after you finish your readings with con.Close()
.
Also you have to put everything in try catch block so your code should be
MySqlConnection con = new MySqlConnection(dataString);
try
{
con.Open();
(rest of your code)
con.Close()
}
catch
{
(something went wrong)
con.Close();
}
EDIT: I don't know if in your connection string you put the port as well. In your first code you have
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
That's the correct format of a connection string.
You didn open the connection.
You have to use con.Open();
so you can establish the connection to the database.
and you have to close the connection as well after you finish your readings with con.Close()
.
Also you have to put everything in try catch block so your code should be
MySqlConnection con = new MySqlConnection(dataString);
try
{
con.Open();
(rest of your code)
con.Close()
}
catch
{
(something went wrong)
con.Close();
}
EDIT: I don't know if in your connection string you put the port as well. In your first code you have
Data Source=192.168.1.1,2222SQLEXPRESS;Initial Catalog=Temp_project;Persist Security Info=True;User ID=userid;Password=password
That's the correct format of a connection string.
edited Nov 26 '18 at 7:00
answered Nov 26 '18 at 6:52
rippergrrippergr
62110
62110
error is not about the open connection ,it is about unable to connect to the mysql host ,real problem is server and the software is not calling to each other because server is running on linux and my software is running on windows thats the problem
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:06
i need to make them talk
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:07
add a comment |
error is not about the open connection ,it is about unable to connect to the mysql host ,real problem is server and the software is not calling to each other because server is running on linux and my software is running on windows thats the problem
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:06
i need to make them talk
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:07
error is not about the open connection ,it is about unable to connect to the mysql host ,real problem is server and the software is not calling to each other because server is running on linux and my software is running on windows thats the problem
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:06
error is not about the open connection ,it is about unable to connect to the mysql host ,real problem is server and the software is not calling to each other because server is running on linux and my software is running on windows thats the problem
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:06
i need to make them talk
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:07
i need to make them talk
– Kãvîñdū Tîssêrã
Nov 26 '18 at 7:07
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475933%2fhow-to-connect-to-a-database-which-is-located-in-a-local-server-in-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
con.open() before da.fill()
– Ravi
Nov 26 '18 at 7:05
Just making sure here, 10.x.x.x is internal IP, so your computer is connected to university network/VPN, right? Also, can you ping the IP from your computer console?
– Martheen
Nov 26 '18 at 7:54
yes i can access and also i can access the database from phpmyadmin using the given ip ,username,password ,i created the database inside the server using phpmyadmin by myself
– Kãvîñdū Tîssêrã
Nov 26 '18 at 8:15