how to connect to wamp server from another computer/different pc - vb.net

I have created an application in VB. I have successfully connected the application to wamp localhost (same computer). But I can't connect it from another computer that is in the same network. Please help me to connect...
here is my code:
Dim server1 As String
Dim client1 As String
Dim cmd As New Odbc.OdbcCommand
server1 = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=db_checkvoucher;User=root;Password=;Option=3;"
client1 = "Driver={MySQL ODBC 5.1 Driver};server=192.168.1.2;" _
& "User=root;Password=;" _
& "database=db_checkvoucher;"
If Form1.TextBox1.Text = "1" Then
con.ConnectionString = client1
Else
con.ConnectionString = server1
End If
cmd.Connection = New Odbc.OdbcConnection(con.ConnectionString)
con.Open()
I am getting this error:
ERROR [HY000] [MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on '192.168.1.2' (10060) ERROR [HY000] [MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on '192.168.1.2' (10060)
I have already run wamp server on the server computer.

It's probably an issue with your firewall on the server.
See here for notes on how to allow mysql connections. http://portforward.com/english/routers/firewalling/Microsoft/WindowsXPFirewallFirewall/MySQL_Server.htm

Related

Connecting mariaDB on Digital Ocean using R Studio

I installed mariaDB on digital ocean. I set up user name and password. Now, I am trying to connect it through R studio. But, it is not working.
Code I used.
library(odbc)
library("RMariaDB")
con <- dbConnect(odbc(),
Driver = "MariaDB ODBC 3.1 Driver",
Server = "206.189.---.", #droplet IP
Database = "test",
Username = "root",
Password = " ****"
Trusted_Connection = "True")
Error I got :
Error: nanodbc/nanodbc.cpp:983: HY000: [ma-3.1.7]Can't connect to MySQL server on '206.189.---.--' (10061)
I installed a connection driver on my windows before running these codes on R Studio. What am I missing here?

RPostgreSQL cannot connect to the server

I'm trying to access a PostgreSQL database through R.
I tried the following code:
library(RPostgreSQL)
library(DBI)
drv <- dbDriver("PostgreSQL")
con = dbConnect(drv, #constructs SQL driver
host = MyHost,
port = MyPort,
dbname = MyDbname,
user = MyUser,
password = pw)
I already have PostgreSQL installed on my computer.
With all my credentials being correct, I still get this Error:
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect [MyUser]#[MyHost] on MyDbname
any ideas what causes the problem? The same problem here has no solution yet. Thanks for your help
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)
Kasia
At the end, I managed to connect to the database with RPosgres package
install.packages("devtools") and load them
devtools::install_github("RcppCore/Rcpp")
devtools::install_github("rstats-db/DBI")
devtools::install_github("rstats-db/RPostgres")
con <- dbConnect(RPostgres::Postgres(),
host = MyHost,
port = MyPort,
dbname = MyDbname,
user = MyUser,
password = pw)
res <- dbSendQuery(con, "SELECT * FROM orders LIMIT 10")
dbFetch(res)
dbClearResult(res)

Connection String Error (error : 40)

I have installed SQL Server 2012 Express on a Windows Server 2008 Machine. The name of the machine is "THEMACHINE". While installation, I set SQL Server 2012 as "Default Instance".
Now I set my connection string like this :
<add name="BooksContext" providerName="System.Data.SqlClient" connectionString="Data Source=THEMACHINE;Initial Catalog=newdb; User ID=sa; Password=123456"/>
But I get this exception :
{"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: Named
Pipes Provider, error: 40 - Could not open a connection to SQL
Server)"}
I checked that database is running. Can you tell me what I'm doing wrong?Thanks.
Reference: Creating and Configuring Universal Data Link (.udl) Files
Do following to Test connection and generate connection string,
1) Create query.udl file in the desktop
2) Double click the file to open and do the following
3)Open the Query.udl in notepad, you will find the connectionstring.
Change Data Source=THEMACHINE to Data Source=THEMACHINE\SQLEXPRESS. Also check that the database service is running.

What would be a connection string for Ironpython to connect to a SQL Server CE?

I'm working with Visual Studio to connect to an IronPython application to a local .sdf database. However, I get this error:
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)
Here's my code:
import wpf
import os
import ConfigParser
import clr
clr.AddReference('System.Data')
from System.Data.SqlClient import SqlConnection, SqlParameter
...
conn_string = "Data Source=" + AppData + "local.static.sdf;Password=[PASSWORD];Persist Security Info=True"
connection = SqlConnection(conn_string)
connection.Open()
command = connection.CreateCommand()
command.CommandText = 'select nom from employee where id = #id'
command.Parameters.Add(SqlParameter('id', 1))
reader = command.ExecuteReader()
buff = ''
while reader.Read():
buff = reader['id']
print buff
connection.Close()
Anyone has an idea about what is going wrong with this piece of code?
Thank you!
~Stéphane
Interesting scenario, wonder if you can make it work...
You need
clr.AddReference('System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91')
and
from System.Data.SqlServerCe import SqlCeConnection, SqlCeParameter

Problems connecting to remote SQL Server using AutoIT

I am attempting to create a login mechanism by which you can access a remote SQL Server 2008 R2 database, in a private network, if the credentials are correct. I intend to implement the database at my work server and this program at a client which is in the same subnet as the server. Here is my code so far:
Func Login()
$loginGUI = GUICreate("Login", 250, 150, -1, -1) ; will create a dialog box that when displayed is centered
GUISetState(#SW_SHOW)
GUICtrlCreateLabel ( "Input valid credentials to login", 40, 10,-1,-1)
GUICtrlCreateLabel ( "Username", 40, 40,-1,-1)
Local $userInput = GUICtrlCreateInput("", 100, 37, 100, 20)
GUICtrlSetState($userInput, $GUI_FOCUS)
GUICtrlCreateLabel ( "Password", 40, 70,-1,-1)
Local $passwordInput = GUICtrlCreateInput("", 100, 67, 100, 20, $ES_PASSWORD)
Local $loginButton = GUICtrlCreateButton("Login", 40, 105, 70)
Local $exitButton = GUICtrlCreateButton("Exit", 130, 105, 70)
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg(1)
Switch $msg[0]
Case $loginButton
$user = GUICtrlRead($userInput)
$password = GUICtrlRead($passwordInput)
Global $loginCon = ObjCreate( "ADODB.Connection" )
With $loginCon
.ConnectionString =("DRIVER={SQL Server};SERVER=192.168.1.30\SQLEXPRESS;DATABASE=Test;UID="&$user&";PWD="&$password&";")
.Open
EndWith
If ($user ="" and $password="") or #error Then
MsgBox(48, "Login error", "Connection failed! Wrong Username/Password.")
GUICtrlSetData($userInput, "")
GUICtrlSetData($passwordInput, "")
GUICtrlSetState($userInput, $GUI_FOCUS)
Else
$loginCon.Close
GUIDelete()
Main()
ExitLoop
EndIf
Case $exitButton
GUIDelete()
ExitLoop
Case $GUI_EVENT_CLOSE
GUIDelete()
ExitLoop
EndSwitch
WEnd
EndFunc
I've also did the following actions:
Used SQL Server Management Studio to allow remote connections as well as the proper permissions for the correct user to access the database.
Used SQL Server Configuration Manager to enable SQL Server Browser and the TCP/IP protocol with the proper configurations to access the server.
Created a firewall Inbound and Outbound rule which allows access to TCP port 1433 and UDP port 1434 for the server and client (just in case).
Added sqlservr.exe and sqlbrowser.exe to the firewall allowed programs list.
Installed SQL Server Native Client 2008 R2 on the client PC.
I could connect locally to my database using the server IP but I get the following error when attempting to connect from the remote client to the server:
err.description is: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
Strangely enough, I could connect from the remote client using sqlcmd. I also have to mention that I am currently using my laptop to hold my test database. It's IP is assigned by the DCHP server from work and always remains the same.
Is my code incorrect or do I have to make additional server/client configurations?
Instead of doing that way I suggest to have client and server written in autoit. Put server to remote computer and make it interact with database locally. Than return what you want to client. This approach is more secure also. Here is where you can start