I just started using Ajax.NET and I ran into an issue. I managed to get
the clock example to work in VB.NET, the problem is when I try to
connect to a SQL database, the function returns NULL instead of the
date and time.

Javascript Code:

function getServerTime()
{
        AjaxTest.WebForm1.GetServerTime(getServerTime_callback);
}
function getServerTime_callback(res)
{
        WebForm1.txtInputBox.value = res.value
        WebForm1.txtInputBox.disabled = true
}

function UpdateTimer()
{
   if(timerID) {
      clearTimeout(timerID);
      getServerTime()
   }
   timerID = setTimeout("UpdateTimer()", 1000);
}


VB.NET Code:

 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        AjaxPro.Utility.RegisterTypeForAjax(GetType(WebForm1))
    End Sub


<AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)> _
    Public Function GetServerTime() As String
        Dim sqlCMD1 As New System.Data.SqlClient.SqlCommand("...")
        SqlConnection1.Open()
        sqlCMD1.Connection = SqlConnection1
        Dim myReader As SqlDataReader = sqlCMD1.ExecuteReader
        While myReader.Read()
        ...
        'End While
        SqlConnection1.Close()
        Return Date.Now
    End Function

Of course in this case the SQL command does nothing, however res.value
becomes NULL if the SqlConnection1.Open() is called. Is there a way
around this or are you not allowed to open Sqlconnections in an Ajax
function? Also I am using AjaxPro, not the version 2. -Allen


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info/

Don't forget to read my blog at http://weblogs.asp.net/mschwarz/
-~----------~----~----~----~------~----~------~--~---

Reply via email to