Calling a date (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


malky800 -> Calling a date (2/6/2006 15:55:48)

When my information gets sent to my database I would like it to also add the current date into a field in my database.
Any suggestions?




rdouglass -> RE: Calling a date (2/6/2006 15:57:16)

If you can post your current query statement and which DB you're using, we can probably come up with it.




malky800 -> RE: Calling a date (2/8/2006 15:30:04)

Currently I have it like this.
I dim every variable and request.form except for the date

Dim query
query= "INSERT INTO Table1 (email, phone, question,date) SELECT '" + email + "','" +phone+ "','"+ question + "','" + date + "'"

When I try to run the page I get an error page.




malky800 -> RE: Calling a date (2/13/2006 10:46:42)

THe date doesn't return anything in my database?




rdouglass -> RE: Calling a date (2/13/2006 10:52:52)

quote:

question + "','" + date + "'"


Try this:

...question + "','" + date() + "'"

That help any?




Spooky -> RE: Calling a date (2/13/2006 14:37:41)

Instead of '" + date + "'", you can also just use Now() or GetDate()




malky800 -> RE: Calling a date (2/13/2006 15:41:12)

I'm getting a type mismatch error. What format am i supposed to be set up in Access. Is it bringing down a short date type?




Spooky -> RE: Calling a date (2/13/2006 16:04:13)

With Access youll use # as a delimiter

query= "INSERT INTO Table1 (email, phone, question,[date]) SELECT '" &email& "','" &phone&"','"&question& "',#" & date() & "#"

OR :
query= "INSERT INTO Table1 (email, phone, question,[date]) SELECT '" &email& "','" &phone&"','"&question& "', now()"




malky800 -> RE: Calling a date (2/13/2006 16:18:18)

let's just confirm what i have;
a database with a field called date that is a short date field.
in my asp script i dim a variable called date
then i inserted a script like this

query= "INSERT INTO Table1 (name1, email, question, [date]) SELECT '" + name1 + "','" + email + "','" + question + "','" + heard+ "','" + religion + "','"+ current+"','" +phone + "','"+ formType+ "',#" + date() + "#" + "'"


This is the error i get when i try to run it.

Microsoft VBScript runtime error '800a000d'

Type mismatch

/gotquestions1.asp, line 58




rdouglass -> RE: Calling a date (2/13/2006 16:27:33)

quote:

query= "INSERT INTO Table1 (name1, email, question, [date]) SELECT '" + name1 + "','" + email + "','" + question + "','" + heard+ "','" + religion + "','"+ current+"','" +phone + "','"+ formType+ "',#" + date() + "#" + "'"


Change all your + to & like this:

query= "INSERT INTO Table1 (name1, email, question, [date]) SELECT '" & name1 & "','" & email & "','" ....




malky800 -> RE: Calling a date (2/13/2006 16:38:49)

OK, so now it looks like this.
query= "INSERT INTO Table1 (name1, email, question, [date]) SELECT '" & name1 & "','" & email & "','" & question & "',#" & date() & "#" & "'"

and it tried taking out the last quotations at the end
query= "INSERT INTO Table1 (name1, email, question, [date]) SELECT '" & name1 & "','" & email & "','" & question & "',#" & date() & "#" & "'"

Both don't work.




rdouglass -> RE: Calling a date (2/13/2006 16:43:19)

quote:

..."',#" & date() & "#" & "'"


Should be just:

..."',#" & date() & "#"




malky800 -> RE: Calling a date (2/13/2006 16:48:12)

Sorry, it doesn't work? Any other suggestions?




malky800 -> RE: Calling a date (2/13/2006 16:49:35)

Can it be a problem with my access database field?




malky800 -> RE: Calling a date (2/13/2006 16:53:05)

in access , when I try to make a query a get an error message "syntax error in string in query expression '#" & date& "#"




rdouglass -> RE: Calling a date (2/14/2006 8:50:01)

I think we both can't see the forest because of the trees. [;)]

query="INSERT INTO Table1 (name1, email, question, [date]) VALUES ('" & name1 & "','" & email & "','" & question & "',#" & date() & "#)"

That work any better? If not, directly after that line put this:

Response.write(query)
Response.end

and post what is written to the browser.




malky800 -> RE: Calling a date (2/14/2006 10:50:15)

This is what is says in my browser:


Microsoft VBScript runtime error '800a000d'

Type mismatch

/gotquestions1.asp, line 59


Is it possible, the problem is with my database fields?




rdouglass -> RE: Calling a date (2/14/2006 10:52:48)

quote:

Is it possible, the problem is with my database fields?


Can't tell just yet. Did you put in those 2 lines I suggested so we can see the actual SQL you're sending to the Access DB?




malky800 -> RE: Calling a date (2/14/2006 11:17:37)

yes, and i pasted the results here

Microsoft VBScript runtime error '800a000d'

Type mismatch

/gotquestions1.asp, line 59




rdouglass -> RE: Calling a date (2/14/2006 11:21:20)

quote:

line 59


Sorry 'bout that. It looks like we're never even making it to the "query=" line.

Which is line 59?




malky800 -> RE: Calling a date (2/14/2006 11:41:54)

it's the query = ....




Spooky -> RE: Calling a date (2/14/2006 11:44:11)

Can you post all of your code?




malky800 -> RE: Calling a date (2/14/2006 12:46:36)

starting from where? until there?
Is there an easy way to paste all my script like I see other users doing?




rdouglass -> RE: Calling a date (2/14/2006 13:19:08)

On the posting form, there is a little button that looks like <% and will put two forum tags that you can paste your complete page code between those two tags.

That puts it in one of those scrolling windows.




malky800 -> RE: Calling a date (2/14/2006 13:43:28)

		<%@LANGUAGE="VBSCRIPT" %>

<!--#include file="Connections/commentConn.asp" --> 

<%
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl


MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

MM_abortEdit = false
MM_editQuery = ""

If (CStr(Request("MM_insert")) = "form1") Then 

  MM_editConnection = MM_commentConn_STRING 
  MM_editTable = "Table1" 
  MM_editRedirectUrl = "http://www.kars4kids.org/thankyoukids.htm"

End If

If (CStr(Request("MM_insert")) <> "") Then

Dim name1
dim email
dim question
dim date


name1 = (Request.Form("name1")) 
email = (Request.Form("email")) 
question = (Request.Form("question")) 

Dim query
query="INSERT INTO Table1 (name1, email, question, [date]) VALUES ('" & name1 & "','" & email & "','" & question & "',#" & date() & "#)" 

Response.write(query) 
Response.end 

%>




rdouglass -> RE: Calling a date (2/14/2006 13:56:58)

Is that all of it? It looks like there's more since there's only 50 lines there and you haven't closed this IF..THEN statement here:

If (CStr(Request("MM_insert")) <> "") Then


I would expect a different error.

Are you sure that's the whole page? Is that page named "gotquestions1.asp"?




malky800 -> RE: Calling a date (2/14/2006 15:33:35)

Sorry, I pulled a similiar code I'm trying to work with. I only included the code that pulls to the database, the rest of the page is where I send an auto-response email. it should be 51 lines anyway
		<%@LANGUAGE="VBSCRIPT" %>

<!--#include file="Connections/askRabbiConn.asp" --> 

<%
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl


MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

MM_abortEdit = false
MM_editQuery = ""

If (CStr(Request("MM_insert")) = "form1") Then 

  MM_editConnection = MM_askRabbiConn_STRING 
  MM_editTable = "Table1" 
  MM_editRedirectUrl = "http://www.gottorah.org/thankyoukids.htm"

End If

If (CStr(Request("MM_insert")) <> "") Then

Dim name1
dim email
dim question
dim date

name1 = (Request.Form("name1")) 
email = (Request.Form("email")) 
question = (Request.Form("question")) 

Dim query
query="INSERT INTO Table1 (name1, email, question, [date]) VALUES ('" & name1 & "','" & email & "','" & question & "',#" & date() & "#)" 

Response.write(query) 
Response.end 

 If (Not MM_abortEdit) Then
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = query 
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close
	   
     If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If
End If


%>

and the new error is
Microsoft VBScript runtime error '800a000d' 

Type mismatch 

/gotquestions23.asp, line 44 




rdouglass -> RE: Calling a date (2/14/2006 15:59:04)

One thing I would try at this point is forcing strings into your variables like this:

name1 = trim(Request.Form("name1")&"")
email = trim((Request.Form("email")&"")
question = trim((Request.Form("question")&"")


That should force all of those fields into empty strings if they are null. That help at all?




malky800 -> RE: Calling a date (2/14/2006 16:08:36)

Nope, still the same type mismatch error.




rdouglass -> RE: Calling a date (2/14/2006 16:12:21)

quote:

query="INSERT INTO Table1 (name1, email, question, [date]) VALUES ('" & name1 & "','" & email & "','" & question & "',#" & date() & "#)"


Can you hard code that query for a test?

query="INSERT INTO Table1 (name1, email, question, [date]) VALUES ('Test','Test@testdomain.com','My Question',#01/01/2001#)"

Does that error?




Page: [1] 2   next >   >>

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.15625