Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] VB6 plus mysql database

Status
Not open for further replies.

sk8ter87

Member level 3
Joined
Dec 1, 2009
Messages
55
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Malaysia
Activity points
1,665
Hi guyz,

i'm now working on a website that interacts with vb then it will allow to control hardware through ms comm.
The flow will be like this:
web -> vb ->hardware.
I'm using using mysql as a bridge between Web and vb
The part from web to vb working fine..
my problem is now to control the hardware from vb..
Can anyone tell me how to pass the data from mysql to mscomm?

Hope you guyz will help me..

Code:
Public up, down, lleft, right As Boolean 'to keep track of which buttons are already pressed
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset

Private Sub Form_Load()
cn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SEVER=localhost;DATABASE=rccontrol;UID=root"
cn.CursorLocation = adUseClient
cn.Open

MSComm1.RThreshold = 1
    MSComm1.InputLen = 1
    MSComm1.Settings = "9600,N,8,1"
    MSComm1.DTREnable = False
    MSComm1.CommPort = 1
    MSComm1.PortOpen = True
    If MSComm1.PortOpen = False Then
        'MsgBox "COM " + CStr(MSComm1.CommPort) + " not open"
    End If
End Sub

Private Sub MSComm1_OnComm()
    Dim Data As String
    If MSComm1.CommEvent = comEvReceive Then
       Data = MSComm1.Input
    End If
End Sub

Private Sub Timer1_Timer()
    rs.Open "SELECT * FROM presskey WHERE 1", cn, adOpenStatic, adLockOptimistic
    Label6.Caption = rs(0).Value
    rs.Close
End Sub

The vb file is uploaded below..
 

Attachments

  • VideoCapture.rar
    41.1 KB · Views: 51
Last edited:

use a .net vb, it has inbuilt components for serial port communication.
 

Why don't you try VB.NET rather than VB, with web services to control your hardware directly from the web

Is this your specific requirements? "web -> vb ->hardware"
 

use a .net vb, it has inbuilt components for serial port communication.

I see..so means that we not need to assign the output for serial port communication if compared to VB6..
correct me if i'm wrong.. i'm newbie to vb..

Why don't you try VB.NET rather than VB, with web services to control your hardware directly from the web

Is this your specific requirements? "web -> vb ->hardware"

Hi bassa.. nop..there is no specific requirement..But i choose to use this way since i already created the vb (used to control hardware indoor)..
i have try the coding..but it getting input but not passing tho the mscomm..
Can you explain more bout the VB.NET with web services to control your hardware directly from the web?
I'm new to this and have use vb6 before..
 

Code:
Private Sub Btn_AvailPorts_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_AvailPorts.Click
        ports = SerialPort1.PortName()
        ComboBox1.Items.Add(ports)
    End Sub
    'setting the selected port
    Private Sub Btn_Setport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Setport.Click
        Dim port As String
        port = ComboBox1.SelectedText()
        MsgBox("Port is set")
        MsgBox("Port :" & SerialPort1.PortName)
    End Sub
 Private Sub Btn_setcam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_setcam.Click
If SerialPort1.IsOpen Then
SerialPort1.Write(cam)
SerialPort1.Close()
end sub
the above is an example program in .net vb
tool.jpg
 

hardware control by net can be made by using asp.net more easily
 

Code has been uploaded.. I dunno where and how to pass value to MSComm1.Output from the code.. Hope can someone can help me..
 

Check this logic

Code:
If Not rs.EOF Then rs.MoveFirst
Do While Not rs.EOF
MSComm1.Output rs(0).Value 'rs!Name
rs.MoveNext
Loop
 

Check this logic

Code:
If Not rs.EOF Then rs.MoveFirst
Do While Not rs.EOF
MSComm1.Output rs(0).Value 'rs!Name
rs.MoveNext
Loop

Hi bassa, i tried the code that you give me..but it still not working.. :(
Bro,i will upload the vb file..hope you can help me from that..
 

Hi bassa, i tried the code that you give me..but it still not working..

Any errors that you have observed?. Does it send the date via com1 when you execute "Form_KeyDown", Form_KeyUp" events?

Can you see the data in the label6 when you execute this line "Label6.Caption = rs(0).Value"?
 

Any errors that you have observed?. Does it send the date via com1 when you execute "Form_KeyDown", Form_KeyUp" events?

Can you see the data in the label6 when you execute this line "Label6.Caption = rs(0).Value"?

Hi bassa,

There is no error but it's not working.. for label 6, when i press any key in the web site..it show the ascii value in the label 6. that is it..it like not passing the value to to form_keydown and form keyup events..
 

There is no error but it's not working..

First check your serial sending routine by giving known value (ex MSComm1.Output "sk8ter87")

for label 6, when i press any key in the web site..it show the ascii value in the label 6.

What are the ascii value in the label 6?

that is it..it like not passing the value to to form_keydown and form keyup events..

Check you form key preview property as true in order to activate form key events (as I remember)
 

First check your serial sending routine by giving known value (ex MSComm1.Output "sk8ter87")

What are the ascii value in the label 6?

Check you form key preview property as true in order to activate form key events (as I remember)

Hi bassa,

the ascii value in the label 6 is set at 88 at starting..but when the user press a key in website,it will change to according key ascii value like a = 65

for the key previews,i will change to to true since it is false before this..

but for the serial sending part, i don't understand what i need to do..
 

u can check the serial sending part with hyperterminal program.send the values to serial port by manually typing the codes in hyperterminal and check whether the port and hardware is working.
 

u can check the serial sending part with hyperterminal program.send the values to serial port by manually typing the codes in hyperterminal and check whether the port and hardware is working.

Yup..i have tried it and it is working fine..
 

Hi bassa..manage to solve the problem. thanks alot for ur help..i miss something..
Left now one thing to complete my project now..
I planning to show demo using LAN..I'm using apache to do it.. but when i tried to acces from other pc,it can browse the webpage..but not controlling the hardware..
Can you help me on this..

Thank you..
 

Make sure that the all required library files are installed and registered. Insert some debug messages for some selected important test points and then trace those message while you are browsing the webpage
 

Hi bassa..

In the vb that i created,do i need to add anything like listen to port 80..
or add anything else?
 

If you can browse the webpage and store the data into the MySQL then that is work fine.

Just check whether the data is updated correctly then hardware (insert some debug messages)
 

If you can browse the webpage and store the data into the MySQL then that is work fine.

Just check whether the data is updated correctly then hardware (insert some debug messages)

Hi bassa.

First of all sorry for the multiple thread that i created..

When I tried to run in my pc it's working fine..the hardware can be controlled
but when i tried to run in the local host..it can load the website but not sending the data through..
Hope you can help me on this..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top