Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21278

Calling Java servlets from VB6

$
0
0
I just found out this is easy to do
This isn't a question just wanting to note that it's not only possible but works really well
I setup my Tomcat and can call servlets and pass parameters and get stuff back

I'm using this setup to do some SQL stuff bypassing the need for ODBC and ADO because it's done in JDBC in the Java
And it means I can do DB stuff over the internet. This is a cool feature of VB that you can do

here's a code sample:

Private Function ExecuteSQL(ByVal sSQL As String, ByVal bResultSet As Boolean) As String
Dim http As Object
Dim strURL As String
Dim strPostData As String
Dim strHeader As String
Dim strResponse As String

On Error GoTo Err

Screen.MousePointer = vbHourglass
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")

strPostData = "?Command=" & IIf(bResultSet, "SELECT", "UPDATE") & "&SQL=" & sSQL

strURL = "http://localhost:8080/FirstProject/DBConnector" & strPostData
http.setTimeouts 10000, 10000, 10000, 10000 'For some reason times out sooner than this sometimes

http.Open "POST", strURL, False
http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.Send strPostData
strResponse = http.ResponseText

Screen.MousePointer = vbDefault
ExecuteSQL = strResponse
Exit Function

Viewing all articles
Browse latest Browse all 21278

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>