I am very new to programming. My company gave me some code for debugging. I am testing a Pocket PC application. No matter what ever I do I can't connect to SQL Server.
First I got the error the server doesn't exist. Second time I have error like server not accessible. I wrote simple code in device application in VS 2008 in vb.net.
The same code runs fine in a Windows forms (I am able to connect to database and pull data). But it fails in device application. I have the following code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim row As Integer
'Dim str As String
con = New SqlConnection("Server=w****b;Database=p***5;User Id=d****;Password=*****;")
con.Open()
cmd = New SqlCommand("select * from emp", con)
row = cmd.ExecuteNonQuery()
If row > 0 Then
MessageBox.Show("the row inserted" & row)
End If
con.Close()
End Sub
I configured the emulator network property as
Enable NE2000 PCMCIA network adapter and bind to
connected network card.
After this I am getting a new error
SQL Server requires Encryption On
I checked the server and encryption is already enabled.
Does anybody know how to connect to SQL Server using emulator? It is high priority job and I am stuck because I can't do anything unless I am able to connect to a database. Any help would be appreciated.
AFAIK the NE2000 emulated networc card is not available since Windows XP. When I need a network connected Emulated Windows Mobile image, I 'dock' the running emultaed mobile device using the Device Emulator Manager (part of standalone device emulator package). Then with WMDC (ActiveSync) active on the development PC and Connection:DMA enabled, the emulated evice get's connected to the PC's network.
On the SQL Server TCP/IP Transport must be enabled. In the connection string use the IP-address of the sql server.
I did not see the "connection must be encrypted" error with standard setups.
You should also look at the SQL Server's event log for the connection error.
BTW: you can run the Windows Mobile compiled exe also on PC as long as the code does not use Mobile-only API functions.
Related
i made application using VB.Net and everything is working fine on my PC at home, i wanted to start using it at my work network i installed mysql community on windows 2012 server with successful connection and that server is under domain and i logged in as admin
when i setup my application on the other machines of users i got message of unable to connect with mysql.. my understanding of this is the problem with my connection string the connection string i used is
if i try the connection string on the server machine it will work and connect
Dim conn As New MySqlConnection("server=localhost;userid=root;password=mmm123;database=dam;sslMode=none")
OR
Dim conn As New MySqlConnection("server=127.0.0.1;userid=root;password=mmm123;database=dam;sslMode=none")
but on user machine it will not it will give unable message and i even tried using ip address but still the same problem
Dim conn As New MySqlConnection("server=xx.xx.xx.xx;userid=root;password=mmm123;database=dam;sslMode=none")
can you please lead me from where i should start with
thank you in advance
I'm trying to write a straightforward piece of code to connect to a MySQL database.
Sub DBConnection()
Dim conn As New ADODB.Connection
Dim connectionStr As String
connectionStr = "DRIVER={SQL SERVER} ;SERVER=localhost; database=sakila; uid=test1; pwd=123"
conn.Open connectionStr
conn.Close
MsgBox "Connected!"
End Sub
I am faced with this error when I run it:
I suspect the details I am providing in the connection may be incorrect but I'm not sure.
User and database name in the MySQL workbench:
Perhaps it's the server name but as I understand it being on my local machine it should be localhost.
Would appreciate any help on this, thanks!
I have the following MYSQL products installed
I have installed the 5.2 driver and followed the connection string for 5.2 from the website provided. The error is still persisting (see below). I'll keep googling but any help would be appreciated as I am very new to this.
My first stop for connection strings is connectionstrings.com, where you should e able to find a connection string that fits your MySQL version and your connection method.
The standard MySQL connection string is:
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
...and several others on the site for various situations.
Sorry for possible dublicate.
I am trying to connect to my MySQL database from my LotusScript code (in some of my legacy projects):
Option Public
Option Declare
UseLSX "*LSXODBC"
Sub Initialize
Dim mysqlConnection As New ODBCConnection
Dim sqlQuery As New ODBCQuery
Dim result As New ODBCResultSet
Call mysqlConnection.ConnectTo("url","root","111111")
If Not mysqlConnection.IsConnected Then
MessageBox "No connection. Try again later."
Exit Sub
Else
MessageBox "Connection success."
End If
End Sub
I can't figure out what is the correct way to set the url of my database in LotusScript. I have already tried many variants of possible solutions, but nothing worked, also found many different urls, but also not helped.
Situation:
For example, I am trying to connect to my localhost MySQL base in port 3306 with name "test_db".
Question:
How must the url looks like for this?
p.s. also, if you have more possible ways to connect to MySQL DB from LotusScript - I will be very glad to see them.
Thanks.
As per the documentation for the ConnectTo method of ODBCConnetion class, you don't specify a URL. You specify a Data Source Name, otherwise known as a DSN. This is a name that you assign when you configure a connection in the 'Data Sources (ODBC)' tool on the Windows machine where the code will be executing.
On Windows 10, the 'Data Sources (ODBC)' tool is found in the Control Panel listed under Administrative Tools. On a Windows 2008 server that I happen to have handy, Administrative Tools is directly on the Start Menu. I'm sure they've hidden it in other places on other Windows versions. (I have a dim memory of it being under 'Accessories' on some versions.)
Note that on 64 bit versions of Windows, you need to be cognizant of whether your code is running in a 32 bit environment - as it is if it runs in the Notes client, or in a 64 bit environment, which it might be if it is running in background on a Domino server. There are separate 32 and 64 bit versions of the 'Data Sources (ODBC)' tool, and it does matter which one you use. If you're at all unsure, run them both and configure the same DSN name in each of them,
It has been a long time since using VB6 and I didn't use MySql or DSN connections then, but I'm working on a legacy application that uses these. When I try to open the connect I am getting a
Data source not found and no default driver specified with this code
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim sql As String
Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command
Set conn = New ADODB.Connection
conn.Open "DSN=AddressHealthcheck" '<- Fails on this statement
I have also tried specifying the DSN in the conn.ConnectionString but get the same error.
The AddressHealthcheck exists in the local System DSN, uses the MySql ODBC 5.1 Driver and connects successfully when tested.
I'm sure (and hope) I missing something obvious. Any suggestions?
Thanks,
Kevin
I use a DSN-less ODBC stored in a UDL. It's basically a file with a connection string in it. Maybe the connection string will be of use. Here's an example:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=MSDASQL.1;Persist Security Info=True;Extended Properties="Driver=MySQL ODBC 5.1 Driver;SERVER=mysqlsvr;UID=userid;PWD=password;DATABASE=mydatabase;PORT=3306;OPTION=18475";Initial Catalog=mydatabase
rags comment (above) wasn't the solution, but it definitely helped track it down.
When using a full connection string the error message was different and much more useful, the driver failed to load.
The issue seems to be that since I'm on a 64 bit machine it was the 64 bit driver. VB6 can't use the 64 bit driver and the 32 bit driver doesn't show up in the ODBC Connection Administrator on a 64 bit machine.
DSN is not an option in my machine.
There are two ODBC Admin tools in a 64-bit system. Run the 32-bit version. Or better yet drop ODBC and get an OLEDB Provider for MySQL.
I was researching this by 1 labour day (yesterday). Today I've realized some errors I had yesterday in order to have this working.
Dim conexion As New ADODB.Connection
conexion.ConnectionString = "DSN = yourDsnName"
conexion.open
Don't forget to...
Create a user in your mysql server that has all the priviledges you need.
Assign the server's name or ip from where it is going to connect to mysql
Create your dsn on the client machine with the correct options en test it.
I am trying to set up a legacy site written in ASP Classic on my local machine. I am using SQL Server 2008 and IIS ver 7.5.
I am running into an error when I try to open a connection to the database.
I used the advice in this post
to use a .udl file to create and test my connection string so I know the connection string works. I am using Windows Authentication and I am certain the app pool that is running this site has access to the database as I use the same pool for multiple sites and they can all connect fine.
When opening the connection I am trying to run a stored procedure, if I just write out the stored proc string and run it directly in my database it works as expected.
Here is the code:
Const adUseClient = 3
Const adCmdStoredProc = 4
Const adOpenStatic = 3
Const adLockBatchOptimistic = 4
dim connectstring,sql
connectstring = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=my-database;Data Source=(local)\SQLEXPRESS"
sql = "MyProc '" & param1 & "','" & param2 & "'"
set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockBatchOptimistic
' this is where it is failing
rs.Open sql, connectstring, 3
One of the problems is the error I get seems to be generated by IIS, it simply says:
An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error.
When I click on the "click here" link it takes me to a general page about running ASP Classic sites on IIS 7, I couldn't find anything that seemed relevant to my error though. I can't seem to find where to get information about the error. As a last resort I checked in Event Viewer->Windows applications logs but there was no entry for my errors.
I've Googled and tried multiple permutations on the connection string but to no avail. If anyone had any advice on how to solve this problem, or even an idea of where to look for a solution I would be grateful. Thanks much!
**EDIT: **
Ok I changed IIS settings to show errors in the browser and now I am getting an error message that is a bit more useful, here it is:
Microsoft OLE DB Provider for SQL Server error '80004005'
Cannot open database "rw-gp" requested by the login. The login failed.
Now when I Googled this I found that this can often be a permissions issue. As you can see I am using Windows authentication and I am running the site under an app pool that has permission to connect to the database. I have multiple ASP.NET sites set up locally that run in this app pool and they can connect using integrated security. I'm not sure what is going wrong, does anyone have any suggestions?
An ASP Classic script always runs using impersonation (this is different from ASP.NET where impersonation is off by default).
Hence the user that needs access to the DB by virtue of your use of SSPI needs to be the user being impersonated.
The impersonated user is by default the the IUSR account specified as the anonymous user however if you have turned on windows integrated security then user may well by the user account the the client browser is running under. In either case you need to make sure that the user being impersonated has access to the DB or stop using SSPI.
If you are only using anonymous access you can specify via IIS manager that the account to use for anonymous access is the app pools identity.