Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP.NET (Non-Forum Related)
 Display value of variable
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 17 April 2006 :  18:11:25  Show Profile
In an asp.net script I have, written by Dayve, I get an error with the SQL Query. But the error doesn't show the query executed. So I need a way to display the query so i can see why it is giving an error.

strSQL = "INSERT INTO FORUM_IMAGES (I_LOC, I_DESC, I_MID, I_DATE, I_SIZE, I_HEIGHT, _
   I_WIDTH, I_TYPE) VALUES ('" + UploadedFileName + "', '" + UploadedDesc + "', " + _
   MemberID + ", #" + DateTime.Now + "#, " + IntFileSize + ", " + IntFileHeight + ", " + _
   IntFileWidth + ", '" + FileType + "');";
conImages = new OdbcConnection(myConnString);
conImages.Open();
cmdImgIns = new OdbcCommand(strSQL, conImages);
cmdImgIns.ExecuteNonQuery();
The error was:

ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-4.1.16-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

So I need a way to display the contents of strSQL. I would usually use a Response.Write with vbscript, but am lost as to how to do this in .net. Using C# I think it is.

Support Snitz Forums

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 17 April 2006 :  18:34:54  Show Profile  Send ruirib a Yahoo! Message
You can still use a


Response.Write(strSQL);


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 17 April 2006 :  18:41:42  Show Profile
Really? Ok, how do I stop execution of the script? Will Response.End still work too? Because it will keep executing until it reaches the query execution and show the .net error message.

Edit: Never mind, I got it. lol Thanks Rui.

Support Snitz Forums
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 17 April 2006 :  20:52:42  Show Profile  Send ruirib a Yahoo! Message
.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 18 April 2006 :  12:22:15  Show Profile  Visit dayve's Homepage
hey Davio... you got my image script running on a MySQL backend? how many modifications did you have to make (if any)?

Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 18 April 2006 :  13:30:01  Show Profile
Yup. hehe Not a lot. It was fairly easy. Just had to use Odbc instead of Oledb. Added the
<%@ Import namespace="System.Data.Odbc" %>
namespace in place of the Oledb one. And changed all the Oledb... functions with Odbc... functions. It seems Odbc has similar functions as the Oledb, like the OdbcConnection() and OdbcCommand(). Changed the connection string to mysql of course. Changed the SELECT @@IDENTITY query to SELECT LAST_INSERT_ID();.

That was it.

You can also use MySQL .net connector instead of Odbc, but just went with the default instead of installing a new driver.

Support Snitz Forums
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000 Version 3.4.07