B4X:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="VB.aspx.vb" Inherits="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
table
{
border: 1px solid #ccc;
border-collapse: collapse;
background-color: #fff;
width: 200px;
}
table th
{
background-color: #B8DBFD;
color: #333;
font-weight: bold;
}
table th, table td
{
padding: 5px;
border: 1px solid #ccc;
}
table, table table td
{
border: 0px solid #ccc;
}
</style>
<script src="../Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "VB.aspx/GetCustomers",
data: "{customerId:" + parseInt($('#Customerid').val()) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Customers");
var table = $("#dvCustomers table").eq(0).clone(true);
$("#dvCustomers table").eq(0).remove();
$(customers).each(function () {
$(".CustomerId", table).html($(this).find("CustomerId").text());
$(".Name", table).html($(this).find("Name").text());
$(".Country", table).html($(this).find("Country").text());
$("#dvCustomers").append(table).append("<br />");
table = $("#dvCustomers table").eq(0).clone(true);
});
}
</script>
</head>
<body style="font-family: Arial; font-size: 10pt">
<form id="form1" runat="server">
<div id="dvCustomers">
<table class="tblCustomer" cellpadding="2" cellspacing="0" border="1">
<tr>
<th>
<b><u><span class="name"></span></u></b>
</th>
</tr>
<tr>
<td>
<b>Customerid: </b><span class="CustomerId"></span>
<br />
<b>Name: </b><span class="Name"></span>
<br />
<b>Country: </b><span class="Country"></span>
<br />
<br />
</td>
</tr>
</table>
</div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
</asp:ScriptManager>
<asp:TextBox ID="Customerid" runat="server"></asp:TextBox>
</form>
</body>
</html>
B4X:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.Services
Partial Class VB
Inherits System.Web.UI.Page
Private Sub VB_Load(sender As Object, e As EventArgs) Handles Me.Load
Customerid.Text = Request.QueryString("customerid")
' GetCustomers(Customerid.Text)
End Sub
<WebMethod()>
Public Shared Function GetCustomers(customerId As Integer) As String
' Dim cust As String
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand("SELECT * FROM Customers WHERE Customerid = '" & customerId & "'")
cmd.Connection = con
Dim ds As New DataSet()
Using sda As New SqlDataAdapter(cmd)
sda.Fill(ds, "Customers")
End Using
Return ds.GetXml()
End Using
End Using
End Function
End Class
please help insert the data returned from my web page into my sqlite database with table called customers which has fileds like customerid,name,country
thiis is my android code
B4X:
'Dim job3 As HttpJob
'job3.Initialize("Job3", Me)
'job3.PostString(ServerUrl, "SELECT [CustomerId], [Name], [Country] FROM [Customers]")
Dim CustID As Int = 3 ' Customer ID
Dim j As HttpJob
j.Initialize("", Me)
'j.Download("http://192.168.43.7/Webandroid/Dtdgrid.aspx?customer=" & CustID)
j.Download("http://192.168.43.7/Webandroid/VB.aspx?customerid=" & CustID)
j.GetRequest.Timeout = 10000 ' 10 seconds
Wait For (j) JobDone(j As HttpJob)
If j.Success Then ' if job is success (http status code 200)
Dim RetVal As String
RetVal = j.GetString
Log(RetVal) ' will print in log value returned from the server
End If
j.Release
i have tried this code below but i get error
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title>
</title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
table
{
border: 1px solid #ccc;
border-collapse: collapse;
background-color: #fff;
width: 200px;
}
table th
{
background-color: #B8DBFD;
color: #333;
font-weight: bold;
}
table th, table td
{
padding: 5px;
border: 1px solid #ccc;
}
table, table table td
{
border: 0px solid #ccc;
}
</style>
<script src="../Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "VB.aspx/GetCustomers",
data: "{customerId:" + parseInt($('#Customerid').val()) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Customers");
var table = $("#dvCustomers table").eq(0).clone(true);
$("#dvCustomers table").eq(0).remove();
$(customers).each(function () {
$(".CustomerId", table).html($(this).find("CustomerId").text());
$(".Name", table).html($(this).find("Name").text());
$(".Country", table).html($(this).find("Country").text());
$("#dvCustomers").append(table).append("<br />");
table = $("#dvCustomers table").eq(0).clone(true);
});
}
</script>
</head>
<body style="font-family: Arial; font-size: 10pt">
<form method="post" action="./VB.aspx?customerid=3" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="ESHM7REoeFFd/EUeDvT3qQDn57kDMHrb76AANirt4Y9VsjmtNbRTLfZXWqD2JoFYDEwzjiGZAOUu86/xFYyzC/O5zpLLT5YpZe2dK/fNtps=" />
<script src="/Webandroid/ScriptResource.axd?d=D9drwtSJ4hBA6O8UhT6CQhtXi0vWKMBmnBUmwlH0BcbPEItzFdJPfBmS2SEK6kYahSd6ohmOFkCz_7K3RLXT1NqEM6ihE3WNIvJNLGXNiBrgHGRIJnuIxY09J8pUFG6R-NNEnyhDI-1W6EIwxiEPX0vgsNt9o_35DAwtplcMJUU1&t=ffffffffd416f7fc" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var PageMethods = function() {
PageMethods.initializeBase(this);
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
}
PageMethods.prototype = {
_get_path:function() {
var p = this.get_path();
if (p) return p;
else return PageMethods._staticInstance.get_path();},
GetCustomers:function(customerId,succeededCallback, failedCallback, userContext) {
/// <param name="customerId" type="Number">System.Int32</param>
/// <param name="succeededCallback" type="Function" optional="true" mayBeNull="true"></param>
/// <param name="failedCallback" type="Function" optional="true" mayBeNull="true"></param>
/// <param name="userContext" optional="true" mayBeNull="true"></param>
return this._invoke(this._get_path(), 'GetCustomers',false,{customerId:customerId},succeededCallback,failedCallback,userContext); }}
PageMethods.registerClass('PageMethods',Sys.N
Message longer than Log limit (4000). Message was truncated.
Last edited: