|
-
Feb 24th, 2007, 07:35 AM
#1
Thread Starter
Addicted Member
MySql Connection [HELP]
I need help in MYSQL connection,
I wrote this script and it say that it doesnt found the database.
VB Code:
Private Sub Form_Load()
Dim sConnect As ADODB.Connection
Dim sRecord As ADODB.Record
Dim sTrconnect As String
Set sConnect = New ADODB.Connection
Set sRecord = New ADODB.Record
sTrconnect = "Driver={mySQL};Server=84.95.241.143;Port=2222;Option=131072;Stmt=;Database=private_test;Uid=private_test;Pwd=private_test;"
sConnect.ConnectionString = sTrconnect
sConnect.Open
sRecord.Open ("select * from `test`")
Label1.Caption = sRecord("title") & sRecord("pass")
End Sub
What is the problem?
BTW : The space in the Uid section in the connection script doesnt exist in the real script
-k3pos
-
Feb 24th, 2007, 07:39 AM
#2
Thread Starter
Addicted Member
Re: MySql Connection [HELP]
I tried this too
VB Code:
Private Sub Form_Load()
Dim sConnect As ADODB.Connection
Dim sRecord As ADODB.Record
Dim sTrconnect As String
Set sConnect = New ADODB.Connection
Set sRecord = New ADODB.Record
sTrconnect = "Driver={mySQL};Server=http://megaserv.co.il;Port=2222;Option=131072;Stmt=;Database=private_test;Uid=private_test;Pwd=private_test;"
With sConnect
.ConnectionString = sTrconnect
.Open
End With
With sRecord
.Open ("select * from `test`")
End With
Label1.Caption = sRecord("title") & sRecord("pass")
End Sub
Ther is a littel change in the connectionstring.
It doesnt work either
-k3pos
-
Feb 24th, 2007, 07:42 AM
#3
Thread Starter
Addicted Member
Re: MySql Connection [HELP]
I tried this too
VB Code:
Private Sub Form_Load()
Dim sConnect As ADODB.Connection
Dim sRecord As ADODB.Record
Dim sTrconnect As String
Set sConnect = New ADODB.Connection
Set sRecord = New ADODB.Record
sTrconnect = "Driver={MySQL ODBC 3.51 Driver};Server=megaserv.co.il;Port=2222;Database=private_test;User=private_test;Password=private_test;Option=3;"
With sConnect
.ConnectionString = sTrconnect
.Open
End With
With sRecord
.Open ("select * from `test`")
End With
Label1.Caption = sRecord("title") & sRecord("pass")
End Sub
BY THE WAY THE DATABASE \ PASSWORD \ USERNAME ARE CORRECT
-k3pos
-
Feb 24th, 2007, 02:39 PM
#4
Re: MySql Connection [HELP]
There was no need for 3 separate posts (you can Edit your posts to add the extra info), and no need to re-post the entire code each time - there was only one line that changed (but I had to read it all to find that out).
You appear to be using connection strings for several different versions of connection software.. what version have you got installed on your computer? (you need to use the appropriate connection string for that).
Has the server been set up to allow MySQL databases, or have you just copied the file(s) to the server? (it needs to be set up)
Your port appears to be unusual.. has that port actually been set up on the server?
Is the server aware of where the database is? (eg: if it is not in the 'root' directory, have you specified the path somewhere?)
Can you connect using other software?
-
Feb 24th, 2007, 02:59 PM
#5
Thread Starter
Addicted Member
Re: MySql Connection [HELP]
Sorry for the three posts i thought it will be easier like that..
1)Yes the mysql is on the network
2)No i dont try tog et other database every time its the same but other servernames
3)The server allows MYSQL database
4)The database exists
I just need an exmaple. the exmples in the site "connectionstrings" arent good, they dont work,, i need real example.
-k3pos
-
Feb 24th, 2007, 03:11 PM
#6
Re: MySql Connection [HELP]
I don't know what questions you were answering, but they weren't the ones I asked.
They are real examples, and they work for many other people (tho I must admit that site is lacking explanations!).
The important things to look at are the parts you have changed (such as the Port and Server), and ensure they are correct for the version of the MySQL connection software that you have installed on your computer. You are likely to find more detailed examples/explanations in the documentation that came with it, or on the web page you downloaded it from.
-
Feb 24th, 2007, 03:19 PM
#7
Thread Starter
Addicted Member
Re: MySql Connection [HELP]
I need an example because i dont understand what to write in ther to make in work
-
Feb 24th, 2007, 03:27 PM
#8
Re: MySql Connection [HELP]
You've already got examples, and you can't get them working, so why do you want more of the same? 
I have already suggested the things you should check, and asked questions about things that are likely to be issues.
Apart from that all I can do is re-iterate where to find more information about what to put in the parameters.. I have never used MySQL, so I can't explain anywhere near as well as the official documentation.
-
Feb 24th, 2007, 03:40 PM
#9
Re: MySql Connection [HELP]
What is the name and path of your database?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 24th, 2007, 10:31 PM
#10
Thread Starter
Addicted Member
Re: MySql Connection [HELP]
Path ?? ther is no path to mysql servers. they on inside the server.
server : megaserv.co.il
server_username : private
server_password : private
database_name : private_test
database_username : private_test
database_password : private_test
-
Feb 25th, 2007, 02:41 AM
#11
New Member
Re: MySql Connection [HELP]
here is what I normally use
create the connection string in a module
VB Code:
Module Module1
Public dbConnection As New ADODB.Connection
Public Inforec As New ADODB.Recordset, SQLSTR As String
Public dbServer As String, dbName As String, dbUser As String, dbPass As String
Public Emp_ID As String, Emp_Dept As String
Public Sub makeMysqlConn()
dbServer = "xxx.xxx.x.x"
dbName = "tracktime"
dbUser = "track"
dbPass = "track"
dbConnection = New ADODB.Connection
dbConnection.ConnectionString = "DRIVER={MySql ODBC 3.51 Driver};" _
& "SERVER=" & dbServer & ";" _
& "DATABASE=" & dbName & ";" _
& "UID=" & dbUser & ";PWD=" & dbPass & ";" _
& "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
End Sub
End Module
then to connect i make a call to the sub
Code:
Private Sub frmTrack_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'call the connectin
makeMysqlConn()
dbConnection.CursorLocation = ADODB.CursorLocationEnum.adUseClient
dbConnection.Open()
If dbConnection.State = 1 Then
cboNames.Items.Clear()
Inforec = New ADODB.Recordset
With Inforec
SQLSTR = "Select * from employee"
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.Open(SQLSTR, dbConnection, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
If .RecordCount > 0 Then
.MoveFirst()
Do Until .EOF
cboNames.Items.Add(.Fields("name_id").Value.ToString & ". " & Inforec.Fields("name").Value.ToString)
.MoveNext()
Loop
End If
.Close()
End With
Inforec = Nothing
dbConnection.Close()
Else
MsgBox("Connection failed", MsgBoxStyle.OkOnly, "Connection State")
End If
End Sub
hope this helps
Last edited by Hack; Feb 25th, 2007 at 05:46 AM.
Reason: Edited out IP Address
-
Feb 25th, 2007, 05:48 AM
#12
Re: MySql Connection [HELP]
CundiRob: I don't know if the IP address you put in your example was real or made up, but it looked real to me.
Therefore, I have edited your post and removed it. It is not wise to post real IP address/user ids/passwords/etc in an open post on an open forum.
-
Feb 25th, 2007, 08:15 AM
#13
New Member
Re: MySql Connection [HELP]
it is a internal ip on a test server that i reimage every other week. on a internal network
but thanks
-
Feb 25th, 2007, 08:47 AM
#14
Thread Starter
Addicted Member
Re: MySql Connection [HELP]
I will try.
VB Code:
Private Sub Form_Load()
Dim sConnect As ADODB.Connection
Dim sRecord As ADODB.Record
Dim sTrconnect As String
Dim dbServer As String
Dim dbName As String
Dim dbUser As String
Dim dbPass As String
Set sConnect = New ADODB.Connection
Set sRecord = New ADODB.Record
dbPass = "private"
dbUser = "private"
dbName = "private_test"
dbServer = "megaserv.co.il"
sTrconnect = "DRIVER={MySql ODBC 3.51 Driver};" _
& "SERVER=" & dbServer & ";" _
& "DATABASE=" & dbName & ";" _
& "UID=" & dbUser & ";PWD=" & dbPass & ";" _
& "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
With sConnect
.ConnectionString = sTrconnect
.Open
End With
With sRecord
.Open ("select * from `test`")
End With
Label1.Caption = sRecord("title") & sRecord("pass")
End Sub
IT doesnt Work What Is The Problem?
-k3pos
Last edited by si_the_geek; Feb 25th, 2007 at 10:13 AM.
Reason: corrected VBCode tags
-
Feb 25th, 2007, 10:16 AM
#15
Re: MySql Connection [HELP]
We can't tell - as you haven't told us what error you are getting, or where it is occurring.
Note that the connection string needs the database username/password (which based on your previous post are both "private_test" rather than "private"), as you are connecting directly to the database, not to the server as a whole.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|