Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Mysql In Visual Basic


14 replies to this topic

#11 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 24 February 2010 - 04:42 PM

VB Login form Mysql In Visual Basic

Hi

I would like to know how to create source code for login form in VB and how to link VB with SQL I'm busy doing project right now Please help 

-reply by Masibulele

#12 Guest_JB_*

  • Guests

Posted 01 January 2011 - 06:07 PM

View Postit01y2, on 23 May 2007 - 07:19 AM, said:

I'm am trying to create a script so that visual basic 6 can interact with mysql

Any ideas?

Answer:
Create a new project. Add a button called Command1.
Paste the code below into the project.
Edit any text between < and > to the appropriate values.
Also, go to the dropdown menu Project/References - and select "Microsoft ActiveX Data Objects 2.0 Library" and click OK.
Download and install - "mysql-connector-odbc-3.51.27-win32.msi"
When you run the project, it will display a message box displaying the content of each record's selected field in turn.
Use the commented out loop bit to restrict the amount of results or to avoid unwanted loops.
It's pretty basic but it works.

Dim strDatabaseName As String
Dim strDBCursorType As String
Dim strDBLockType As String
Dim strDBOptions As String
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection

Private Sub Command1_Click()
On Error GoTo 9
Dim strSQL As String
Dim X As Long
strDBCursorType = adOpenDynamic 'CursorType
strDBLockType = adLockOptimistic 'LockType
strDBOptions = adCmdText 'Options

Set cn = New ADODB.Connection
Me.MousePointer = 11 'sets pointer to hourglass
cn.Open ConnectString()
With cn
.CommandTimeout = 0
.CursorLocation = adUseClient
End With
Set rs = New ADODB.Recordset 'Creates record set
strSQL = "select * from <your table>"
rs.Open strSQL, cn, strDBCursorType, strDBLockType, strDBOptions
If Not rs.BOF Then
rs.MoveFirst
End If
If rs.EOF Then
MsgBox "No data found"
Else
For X = 1 To rs.RecordCount
MsgBox rs.Fields("<your field>").Value
rs.MoveNext
'If X > 100 Then GoTo 10 'use this to avoid getting stuck in loops during development
Next X
rs.Close
Me.MousePointer = 0 'sets pointer to normal
End If
GoTo 10
9
MsgBox "Error - I'm out of here!"
10
End Sub

Private Function ConnectString() As String
Dim strServerName As String
Dim strDatabaseName As String
Dim strUserName As String
Dim strPassword As String

'Change to IP Address if not on local machine
strServerName = "localhost"
strDatabaseName = "<your database name>"
strUserName = "<your username>"
strPassword = "<Your password>"

ConnectString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=" & strServerName & _
";DATABASE=" & strDatabaseName & ";" & _
"USER=" & strUserName & _
";PASSWORD=" & strPassword & _
";OPTION=3;"

End Function

#13 Guest_Aaron2_*

  • Guests

Posted 17 February 2011 - 07:05 PM

Galahad

Could you supply another location or way of getting your files for this post?
Planetsoucecode is producing vb script errors when I try to register.

#14 vinods

    Newbie

  • Kontributors
  • Pip
  • 4 posts

Posted 01 March 2011 - 11:31 AM

while using VB 6.0 you can interact with the mysql using database connectivity to your application

you have create a tables in Microsoft Access & then open the visual basic application window using connnection string properties

you can write sql query in your application code you will get the excepted result that you want in the application

for e.g if you want to retriew the list customers table

"select * from customers "

#15 Guest_Uma_*

  • Guests

Posted 16 June 2011 - 09:03 AM

Dear Sir /Madam!

I tried to insert data into mysql database using vb.net 2008. When i click Save Button it Showing Error message"There is No Source Code Available in Current Location!"Please Tell me Solution for my Problem.




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users