Developer forum

Forum » Development » ExecuteNonQuery

ExecuteNonQuery

Aki Ruuskanen
Reply
I have som code to insert a row into a table. Looks like below.

The SQL itself is OK, I have checked it and run it in Query Analyzer and the row gets inserted. 

When I run the ExecuteNonQuery it returns 0 but nothing is inserted in the table. Very strange. Any ideas?

sql = "insert into MFAnalytics(MFAnalytics_UserID, MFAnalytics_Domain, MFAnalytics_Page, MFAnalytics_Date)";
sql += " values('value1', 'value2','value3',getDate())";

return Dynamicweb.Database.ExecuteNonQuery(sql, @"dbname");


Regards  /Aki
 

Replies

 
Nicolai Høeg Pedersen
Reply
Have no idea.

Can you catch the insert with the SQL Profiler when running your code?

 
Aki Ruuskanen
Reply
Unfortunatly no, it's on a Express solution.

Here is how it works:

I have a domain (domain1.se) that is not a DW solution. In that domain there is a page that retrieves a script from a DW solution:

<script scr="path/to/script/on/dw"/> 

Thats script does a Ajax POST a aspx page with a webmethod, that page is on the DW solution. And the webmethod does the insert in my first post. And I know that the webwethod is executed as it should and also the ExexuteQuery.

Does that help anything?

Regards / Aki
 
Nicolai Høeg Pedersen
Reply
No - usually you cannot do cross scripting things like this - the browser would not allow it. Are you sure that the ajax post i actually handled? And what happens if you just make the post not using ajax, but simply the browser from a form on the same domain?
 
Aki Ruuskanen
Reply
The method is executed.

The return Dynamicweb.Database.ExecuteNonQuery(sql, @"dbname"); returns a value that I outout from the script.

If I put the code in PageLoad and run it it works just fine.

Regards / Aki
 
Nicolai Høeg Pedersen
Reply
It must be something in your post then - data not present, or wrong parameters or something...
 
Aki Ruuskanen
Reply
This post has been marked as an answer
Solved it.

In the script, instead of calling a webmethod with $.ajax I just do a $.get and send in the parameters in the querystring.

Works like a charm.
Votes for this answer: 0
 
Nicolai Høeg Pedersen
Reply
Glad to hear!

 

You must be logged in to post in the forum