🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.csharpbuilder.language.csharp
4 messages
4 total messages Started by M. Noroozi Eghbali Wed, 24 May 2006 22:13
Database problem using AJAX
#38
Author: M. Noroozi Eghbali
Date: Wed, 24 May 2006 22:13
26 lines
1607 bytes
Hi all,

I hope this group is the correct position for my question. I have a problem 
writing a record from an access database using AJAX. suppose the below code:

public void SaveData()
{
    try
    {
         bdpDataAdapter1.Active = true;
        //...writing data...
    }
    catch
    {
    }
}

When I call the function in a normal OnCLick event of a ASP:Button, the 
function works properly, but when I call it using AJAX methode, at the first 
line of the function, an exception is occured and nothing is added to the 
database.

Would you please let me know what is my mistake?

Thank you,
Mehrdad
Re: Database problem using AJAX
#40
Author: Marc Rohloff TeamB
Date: Thu, 25 May 2006 02:31
10 lines
1467 bytes
On Thu, 25 May 2006 01:43:51 +0330, M. Noroozi Eghbali wrote:

> Would you please let me know what is my mistake?
You are really going to need to show a bit more code and also tell us
what exception you get. 
Also which AJAX libraries are you using?

-- 
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Re: Database problem using AJAX
#41
Author: M. Noroozi Eghbali
Date: Thu, 25 May 2006 08:18
108 lines
3622 bytes
Thenk you for your response.

I am using AjaxPro 6.5.17.1 http://www.ajaxpro.info/ for .NET 1.1.

This is the Javascript I am using to call the function:
-----------------------------------
<script language="javascript">
function getServerTime()
{
   TBNet.Index.SaveData(document.getElementById('Downloads_Email').value,
        true,
         document.getElementById('Downloads_Fullname').value,
         document.getElementById('Downloads_Organization').value,
         'Test', getServerTime_callback);
}

function getServerTime_callback(res)
{
    alert(res.value);
}
</script>
-----------------------------------

And this is the code I used for the Ajax function:

-----------------------------------
[AjaxPro.AjaxMethod]
public String SaveData(String EmailAddress, bool SendNews,
    String FullName, String Organization,
    String DownloadedFileStr)
{
 int RowNum = 0;
 String CommandStr;

 try
 {
  bdpDataAdapter1.Active = true;
  bdpConnection1.Open();
  BdpTransaction Trans = (BdpTransaction) bdpConnection1.BeginTransaction();

  bdpDataAdapter1.SelectCommand.CommandText = "SELECT * FROM Info WHERE 
Email = '" +
       EmailAddress + "'";
  bdpDataAdapter1.FillSchema(dataSet1, SchemaType.Source, "Info");
  RowNum = bdpDataAdapter1.Fill(dataSet1);

  bdpConnection1.Close();
  BdpConnection Connection = new 
BdpConnection(bdpConnection1.ConnectionString);

  if(RowNum == 0)
  {
   CommandStr = "INSERT INTO Info (Email, SendNews) VALUES ('" +
     EmailAddress + "', " +
     (SendNews ? "true" : "false") +
     ")";
   BdpCommand Command = new BdpCommand(CommandStr, Connection);

   try
   {
    Command.Connection.Open();
    Command.ExecuteNonQuery();
   }
   finally
   {
    Command.Connection.Close();
    bdpConnection1.Close();
    bdpDataAdapter1.Active = false;
   }
  }

  Trans.Commit();
 }
 catch
 {
  return "Test failed";
 }

 return "Test success";
}
-----------------------------------

I don't know what is the Error message, but after executing the first line 
of the Ajax function, the "catch" part is running.

Thank you in advance,
Mehrdad









"Marc Rohloff [TeamB]" <"on request"> wrote in message 
news:1993c9wwxgx7y$.dlg@dlg.marcrohloff.com...
> On Thu, 25 May 2006 01:43:51 +0330, M. Noroozi Eghbali wrote:
>
>> Would you please let me know what is my mistake?
> You are really going to need to show a bit more code and also tell us
> what exception you get.
> Also which AJAX libraries are you using?
>
> -- 
> Marc Rohloff [TeamB]
> marc rohloff -at- myrealbox -dot- com 
Re: Database problem using AJAX
#42
Author: Marc Rohloff TeamB
Date: Fri, 26 May 2006 00:16
11 lines
1605 bytes
On Thu, 25 May 2006 11:48:23 +0330, M. Noroozi Eghbali wrote:

> I don't know what is the Error message, but after executing the first line 
> of the Ajax function, the "catch" part is running.

I have never used AjaxPro but I suspect that your bdpAdapter1 (and
other) objects are not created automatically.

-- 
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads