Converting String To Datetime Insert Into Sql Table
I am having terrible time in converting a string to a datetime field in my asp page. I am keep on getting error on the following stateement. What would be the correct syntax on converting string to datetime for inserting into a sql table?? I did write the add_str out on the browser, everything looks correct...
Error message:
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting datetime from character string. Code:
View Replies
ADVERTISEMENT
I have a form that collects the date and time of an event.
I create a string to hold all of the data in the correct format for MySQL and it (the string) looks like this...
2007-03-03 17:30:00
I am then using CDate to convert the string to a DateTime type.
and since I am in the US it gets converted like this...
3/3/2007 5:30:00 PM
per my regional system settings...
I grabbed this code from the forums here which I have used before...
Function ISODate( dt )
If Not IsDate( dt ) Then
ISODate = "NULL"
Else
dt = CDate( dt ) ' safety
ISODate = "'" & Year(dt) & "-" & Month(t) & "-" & Day(dt) & "'"
End If
End Function
ISODate = "'" & Year(dt) & "-" & Right("0" & Month(t),2) & "-" & Right("0" & Day(dt),2) & "'"
My question is How do I modify it to add the time to the ISODate function and then include it in my insert statement correctly?
View Replies
View Related
I have a form that collects the date and time of an event. I create a string to hold all of the data in the correct format for MySQL and it (the string) looks like this...
2007-03-03 17:30:00
I am then using CDate to convert the string to a DateTime type.
and since I am in the US it gets converted like this...
3/3/2007 5:30:00 PM
per my regional system settings...
I grabbed this code from the forums here which I have used before... Code:
View Replies
View Related
I'm using ASP, VBScript, ADO for SQL server 2000. I have a stored procedure that I'm trying to use to insert a row using parameters. One of the field is date. Here is the parameter for that. Code:
Set param = cmd.CreateParameter("theDate", adDBTimeStamp, adParamInput, Date())
cmd.Parameters.Append param
But I'm getting this error. Error converting data type varchar to datetime.
View Replies
View Related
there is an old asp application that is moved from one machine to the other.On the one machine its working fine, but on the new one, when trying to insert from the asp page(variables from the asp page), i get this error, Error converting data type varchar to datetime.
I have tried almost everything, from checking the order of variables, but still get the error. When the proc is executed on SQL it runs fine, am i maybe missing something?
View Replies
View Related
I have migrated ASP pages and SQL SERVER database from a development server to the Live SERVER the regional settings are fine both set to use UK date dd/mm/yyyy. But I have that stupid error when I try to run a stored procedure EXEC sp_add_user 1,'28/08/2004 10:00:00'.... on the live server and not on the development one. I dont want to redevelop all my stored procedures.
View Replies
View Related
This is part of an expense reporting application that I'm trying to recreate for a client. Client logs in and is shown a date. The date shown lets them know that they are entering info for the month after their last report (which is why we can't use Now(). The months have to be entered sequentially.This part is working fine.
I have a hidden field that holds the same date variable that I need inserted back into the same db. When they submit the form, they get a results page telling them everything went through. Everything is being inserted correctly to the database except for the datetime. It gets inserted incorrectly like this 0000-00-00 00:00:00. Meaning, it's zeroed out everytime even though the hidden field is pulling the date correctly.
View Replies
View Related
i have the following insert statement:
varSQL = "insert into messageCenter(sender,recipient,title,message,sent, ack) values(" & request.form("sender") & "," & request.form("recipient") & ",'" & request.form("title") & "','" & request.form("message") & "','" & now & "'," & 0 & ")"
oConn.execute(varSQL)
for whatever reason, the "sent" field is always blank. it is set to "datetime" in the MySQL DB.
View Replies
View Related
I need to know how can i insert the data that is saved in an excel file into my SQL Server database.. I've seen some websites.. but i dun quite understand them. I would be great of you can explain to me the steps in doing tat etc...
View Replies
View Related
I am passing a string into a page and them looking up info to display from a database based on whats passed in. The link is www.domain.com/page.asp?variable='12345678'
Once inside the page the following code is executed Code:
View Replies
View Related
i am doing this asp programming with vbscript and came across to this problem. i need this answer asap coz i have to submit my assignment tomorrow. the thing is in the code below all the condition under the if statement works EXCEPT where i want to say that 'OrderValue' has to be between 100000 and 999999 inclusive.
it doesnt work i hv used to 'CInt' function to change 'OrderValue' Integer 'OrderValue' contains the text/string entered from the previous page that was entered in a text box called 'txtSearch'
View Replies
View Related
is any way possible to convert a string, which is a string of a number, to an integer (using VBScript). If not, are there any other solutions to have a number that is a string, and add one to increase that number?
View Replies
View Related
I am trying to populate column values from an Oracle database into an HTML "Select" control. The column in the databases is defined as number. It is not working because I think I need to convert the value from the databases into a string variable first.
View Replies
View Related
I need some advice in converting a line of string into array. For example; "001,002,003,004,005,..." into 001, 002, 003 and so on. How can I do this?
View Replies
View Related
Is there any function or some code to convert string to unicode directly or ( string to ascii and then ascii to uniccode ).
View Replies
View Related
i got some text fields im submitting by a form and i need to add the field to the current field in the table but the field is text in the table so when i do this
request.form("dkp1") + getraids.fields.item("dkp1").value
i have dkp1 = 10 from the form
and 20 in getraids field
and the above calculation it dosn add but puts them to getter as a string like 1020 and i need to calculate it to 30. my real question is there a way u can define the request.form(dkp1) to be converted from text to numberic ? and getraids of course or do i realy need to change the field type in the table ?
View Replies
View Related
Am collecting numerical entries from text boxes and converting to numbers using:
F1 = Round(CDbl(Request.Form("amout1")),2)
F2 = Round(CDbl(Request.Form("amount2")),2)
F3 = Round(CDbl(Request.Form("total")),2)
F4 = F1 + F2
If F4 <> F3 Then
Session("ErrorMessage") = Session("ErrorMessage") & "- Your control amounts do not tie to the Total Deposit amount.<br>"
End if
etc.
Sometimes it works, but other times, although the numbers tie out, the calculated amounts are not coming up as equal. I've written the results (F3 & F4) to the screen and they equal, although the server doesn't think so.
Is this an issue with binary number conversion or something. Should I be using something other than CRnd (Delphi has something like C$ or CCurrency)??
View Replies
View Related
I have the following stored procedure:
CREATE PROCEDURE [dbo].[GET_CategoryCurrentNewsList]
@Category VARCHAR
AS
BEGIN
SELECT dbo.News_Joined.NewsTitle, dbo.News_Joined.NewsID
FROM dbo.News_Joined
WHERE (dbo.News_Joined.StartDate <= GETDATE()) AND (dbo.News_Joined.EndDate >= GETDATE()) AND (dbo.News_Joined.CategoryID IN (@Category))
END
GO
dbo.news_Joined.CategoryID is an INT, and @Category is a string such as (1000, 1010, 1020). However, no results are returned. I figured I had to do something to do some string conversions from INT to VARCHAR or something, but I can't use CSTR. I do not know how many numbers will be passed to @Category, so making seperate variables isn't an option.
Any ideas???
View Replies
View Related
I'm passing a unique identifier from page1 to page2 to page3 querried from MS SQL Server. When I pass the value, it puts the value in the curly brackets. (Page1 is for display and Page2 is for edit and Page3 is update edit)
When I go to Page3, it gives me an error saying "Syntax error converting from a character string to uniqueidentifier" {7171B9BD-4599-43D9-9521-3DA583A1BB1A} This is the value and the error page says "id=%7B7171B9BD-4599-43D9-9521-3DA583A1BB1A%7D" It seems tp put "%7B" and "%7D" for "{" and "}". Has anyone seen this?
I'm also passing numbers and text and they don't seem to have this problem, just the unique key.
View Replies
View Related
if my month is represent by numbers. like 2, 4, etc
i recognize this as a string but then i want to store it as int
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value '2, 2, 2' to a column of data type tinyint.
/ords/asp/custorder_view.asp, line 41
u can see the varchar value to colum of data type tinyint
View Replies
View Related
I'm using Msxml2.ServerXMLHTTP.3.0 to fetch a HTML page on a remote
server. The fetched page is then parsed and the information of interest
is extracted and send to the client browser.
However, the remote server does not specify any character coding in its
headers. If using ResponseText property in ServerXMLHTTP, some
international characters are not decoded correctly. This is due to
ResponseText assuming UTF-8 coding if no character set is specified.
My solution is to use the ResponseBody property which returns the web
page as an array of unsigned bytes. I then convert the data to a string
using the ADODB.Stream method as described here:
http://www.motobit.com/tips/detpg_binarytostring/
The string is then parsed and the required information is pulled out.
This solution works just fine but I wonder if there is some more
efficient (without the need for a byte to string converion) way to
solve the problem.
View Replies
View Related
I have created an empty table(.mdb) with 2 columns
Order(AutoNumber) and BuildingID(text)
and i use :
cn.execute "Insert into [Temp](BuildingID) values ("&Buildingid&") "
to insert buildingID into the table
however all buildingid start with 0 with be omitted,
eg. buildingid = "00003333" after insert into the table become "3333"
i have checked that response.write len(buildingid) = 8
What is the problems?
View Replies
View Related
I am trying to make a page post.asp with a form that simply submits one text value and two hidden values into a table. I already have the function that takes the 3 parameters, modifies them and successfully inserts them into the table:
I have included this function in this post.asp page ...
View Replies
View Related
I would like to clean up my mailing list by changing the URL I use at the moment which is in the format
www.mysite.com/view_pic.asp?pic_number=123
To be
http://www.mysite.com/view_pic.asp?p...il=bob@bob.com
it would then insert the email into a table, collect these for a while and only see these as active members.Any ideas how to do this, I've tried a few things but no luck.
View Replies
View Related
I have a problem that it's bothering me for some time now and i will need a lot of help from you. I don't know how easy or difficult it is to be done but i would appreciate any help.
I have an mssql 2000 db with table "table1". Attributes for "table1" are:
ID (Primary Key)
field1
field2
field3
field4
field5
field6
field7
I'm trying through DreamWeaver MX to create a form through ASP and Text Fields, so that i can update "table1" through the form and also on another page to show the results of my table.
I have created a form which will be accepting 25 rows, each row having field1, field2, .., field7.
I cannot seem to get it to update "table1".
Any ideas how this can be done?
View Replies
View Related
Does anyone know how to insert multiple records in the same table at the same time. This is what I have. I have a form with 6 fields and they are name prod1 through to prod 6. The table is called related products.
Basically this table is related to the main table called prod_parent. tried looking on google and couldn't find anything.
View Replies
View Related
I am gathering the input values to a form using Request.form method from the processing page. After all the data is captured, I am building sql statement out of it.
Using a response.write statement, I am generating the output of the sql statement which I can ran against the table to insert the row.
However, when I am trying to programmatically use the sql statement for the insert, I am having the following error:
View Replies
View Related
How can I display the first 20 characters of a long string?How can I insert some character inside of the string on every 5th character?
View Replies
View Related
I am trying to retrieve a record identity from a SQL Server auto-incremented field on insert statement.
Here is the error I am getting can anyone please help me
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert explicit value for identity column in table 'cwm_Report_Request_Form' when IDENTITY_INSERT is set to OFF.
/cwm/Admin/reportrequest.asp, line 66
here is my code:
View Replies
View Related
I have an asp page with a form, which has a lot of fields 30 to 40 .Is there an easier way to loop through all the fields submitted to the insert page or is the only way to do it using the standard, request.form for each field and then INSERT INTO Reports (ReportID, ReceivedDa very lengthy for this amount of fields. Perhaps there is a way of looping through some sort of collection ?
View Replies
View Related
I'm using conn as ADODB.Connection object. when I write:
conn.execute "insert into table (binarydata) values ('" & binarydatastringvariable & "')"
it returns the error:
Unclosed quotation mark before the character string '(here is some string given)'.
How can I insert binary data to a ms sql server 2000 table without using adodb.recordset?
View Replies
View Related
I have the belwo code which i mean to do an multiple checkbox insert. I have managed to get it so i puts all the checkbox values into a string seperated by a comma, and it insert into a database, however just not how i need it to.
Curently inserst like :-
View Replies
View Related
I need to parse a string from a single, semi-colon delimited, 60 character
field (el_text) in a recordset and display the results in a table on a
webpage (ASP)
I can retrieve the recordset from the database and display the field data
results in rows of a table but have the entire 60 character string in one
cell. I need to break that string apart and put each semi-colon delimited
value in it's own cell. Then move to the next record and do the same thing
in the next row of the table. - and so on
I'm using ASP, VB Script with DMSII Database and OLEDB
Does anyone have some code examples on how to break this field apart and
then arrange the data into an html table on a webpage?
View Replies
View Related