Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 This makes no sense at all..... Please help!!

Author  Topic 

Celtics3410
Starting Member

11 Posts

Posted - 2002-06-04 : 13:04:24


OK.. I tested my insert statements, DSN connections, etc. in a new ASP file just called insert.asp, and it worked fine.
'--------------- ASP FILE: insert.asp ----------------------
<%

myDSN="DSN=myDB10;uid=;pwd"
dim conntemp
set conntemp=server.createobject("ADODB.connection")
conntemp.open myDSN

Set rcrdset = Server.CreateObject("ADODB.Recordset")

SQLIns5 = "INSERT INTO Table10 (Field1, Field2, Field3) values('125367','IN','10.10.10.10')"
set rcrdset10=conntemp.execute(SQLIns5)
response.write "^^^ SQLIns5 ^^^"

%>

This worked perfectly. BUT, when I go to the other ASP file and paste the insert statement in there, and made sure that everything matched up, (ie no diff. names were used in the insert.asp file then what I actually had in the real ASP files) it still does absolutely nothing.

'---------------REAL ASP FILE: code for insert---------------
SQLIns6 = "INSERT INTO Table10 (Field1, Field2, Field3, Field5, Field6) value ('10101010','IN','10.10.10.10', 'Sick', '10112532') "
set recset5=conntemp.execute(SQLStmt6)

All fields are text, except the date which is Date/Time. Is there any way to pass a text value that is actually a date and a time (just without the seconds, and the user inputs them)
-=Example of date input=-
[05][24][02] (03)(30)(PM)
Where brackets are small textboxes with a maximum of 2, and parantheses are drop down menus.

Is there some possible cause for the insert statements working in a seperate file (the one listed above), but then no matter what I do it won't work in the real ASP file?

Before you answer:
1) Yes DSN connections are working, I can read from the DB fine. Queries are no problem at all, they run perfectly. Only INSERT statements (even when syntax is exactly what it should be) won't work. I tried taking the date out b/c of the mismatch of text and date and time, and i got nothing.

2) I have no 'on error resume next' statements.

3) I am not getting any error messages, it just wont go into the database.

4) I tried doing a response.write of the SQL Insert Statement, and from the looks it, it makes absolutely no sense at all.

Please help if you can!! I'd greatly appreciate it.

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-06-04 : 13:11:36
i'm not sure i follow your problem. are you asking what the format is for inserting dates? if so, sql server is fairly flexible. try 'yyyy-mm-dd hh:mm:ss'.

setBasedIsTheTruepath
<O>
Go to Top of Page

Celtics3410
Starting Member

11 Posts

Posted - 2002-06-04 : 13:28:08
Sorry if it was unclear, I have such a headache from this right now.. I was asking what could possibly cause an insert statement to work fine in one ASP page, and on another with the exact code won't work no matter what I do?

And if you didn't know that, I was wondering if you could at least help me with this other problem. But anyway, I was using this editor called "EditPlus", and like most editors, it makes the language's keywords and syntax structure show up in a different color. Well I noticed month, date, and year all turned red, the same as int, a data type. Is that how month date and year are used or is it some other way?

The whole purpose of the 'Date' column is for managerial use, so they can enter when one of their employees takes a vacation, a sick day, a holiday, etc.

Currently I have Date in Table10 as Date/Time. It timestamps when the user submitted, down to the second. (ex- 6/4/02 3:21:42 PM) My way of getting the date from the user is through 3 text boxes and 3 drop down menus. The text boxes are split up so that I can do error checking on them easily. Now if they put 02 (February) for the month, they can't pick 30 days, they can't put 20 for the month, etc. With it all as one big string (ex- 06/04/02) it would be much harder if not impossible to do so. I then made a variable to combine those 6 parts, so that the format is almost indentical to the timestamped kind, except missing the seconds part. But I can't put that into the Date column b/c of a type mismatch, and my boss said if I switched it to text he couldnt do some query to see how many hours they were out for, like he could if it was a Date/Time not a Text type.

Thanks again,
Celtics3410@hotmail.com

Go to Top of Page

roffutt
Starting Member

1 Post

Posted - 2002-06-04 : 13:31:15
Check that the uid has permissions to insert into that table?

In the "REAL ASP", what is the value of "SQLStmt6" variable? Looks like you have a typo?



Go to Top of Page

Celtics3410
Starting Member

11 Posts

Posted - 2002-06-04 : 13:36:22
Sorry, that was a typo in the copying over, not in the code. I didn't want to paste over my ASP exactly so I switched around the names of all the tables, columns, and variables. Other than that, it is the same. That typo didn't happen in my code. If this was some personal project I would have copied it exactly but its for a hospital's new timecard system I am working on, so I did that for security reasons... You never know what could end up being a security hole if you give out too much.

Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-06-05 : 10:03:39
try a SET DATEFORMAT DMY (or YMD or MDY if that applies to your location)...before the insert statement....this topic has come up here many a time....search for SET DATEFORMAT for other case histories.


i'd also try executing the code in Query Analyser....if there's an error that's being supressed by the ASP interface...it'll show up there...


also post sample table DDL and the 'actual' sql statement you are executing....i.e. with it's values included....




Go to Top of Page

Celtics3410
Starting Member

11 Posts

Posted - 2002-06-06 : 14:25:40
Figured out what the problem was... They had Timestamp as a column name in one of our tables, and timestamp is a keyword of a language, so it wouldn't allow me to do any kind of query using that column.

Its all fixed now though!

Go to Top of Page
   

- Advertisement -