|
-
Sep 24th, 2016, 10:45 AM
#2
Re: [Newbie] Cloud database on VB6
If you want to develop the client-frontend (the GUI) in VB6, whilst the Data is
(in *.mdb or *.accdb format) hosted "on some server in the internet", then
you will need:
1) either a "managed-server"-contract with some internet-hoster who offers MS-Windows as the Server-OS
2) or a CloudService-Provider who offers entire Virtual-Machines (which in the end run MS-Windows as well)
The latter part (#2) could be e.g. an MS-Azure Worker-Role - but those are usually much more
expensive than a normal virtual (managed) server from a normal Web-Provider (as listed in point #1).
To give you an impression, how #1 above performs and behaves - here's VB6-Code
which can perform SQL-Requests against a Test-Database (NWind.mdb), hosted online
(on vbRichClient.com - "powered" by a normal "about 10Euro-per-month" Windows-WebHosting-contract).
To run the code below, you will only need an "MS Hierarchical Flexgrid" on an otherwise empty Form,
so after you placed the Grid-Control on the Form (as MSHFlexGrid1), you can click the Form and make
a secure https-Request, which hands out an ADODB.Recordset (which then is set as the datasource of the FlexGrid).
Code:
Option Explicit
Private Sub Form_Click()
On Error GoTo 1
Set MSHFlexGrid1.DataSource = PerformNwindRequest("Select * From Customers")
1 If Err Then MsgBox Err.Description
End Sub
Function PerformNwindRequest(SQL As String) As Object
Dim Req As Object, B() As Byte
Set Req = CreateObject("Winhttp.WinHttpRequest.5.1")
Req.Open "POST", "https://vbRichClient.com/asp/ADODBTest.asp", False
Req.SetRequestHeader "Content-Type", "application/json"
Req.Send "{""DBName"": ""/data/NWind.mdb"", ""SQL"": """ & SQL & """}"
B = Req.ResponseBody
If B(0) = 123 Then Err.Raise vbObjectError, , StrConv(B, vbUnicode)
Set PerformNwindRequest = GetRsFromByteContent(B)
End Function
Function GetRsFromByteContent(Data) As Object
Dim Stream As Object
Set Stream = CreateObject("ADODB.Stream")
Stream.Type = 1 '<- 1 = adTypeBinary
Stream.Open
Stream.Write Data
Stream.Position = 0
Set GetRsFromByteContent = CreateObject("ADODB.Recordset")
GetRsFromByteContent.Open Stream
End Function
Olaf
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
|