.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 11th, 2006, 01:45 PM
tetris tetris is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Mississauga, ON
Posts: 5 tetris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 51 sec
Reputation Power: 0
Convert string into SQL datetime value

Ok, I'm totally stuck on this one, here is what I'm trying to do.

I pull a record, and with it I pull the last modification time. Users makes changes and when they go to save them, the system checks if the modification date has changed on that record or not, basically record locking.

So, I have a variable time_stamp that holds that datetime value from SQL server, but when I try to pass it back into the SQL as a parameter I get errors. I have tried so many combinations that I'm stuck. Here is the list:

combo 1:
Code:
Dim time_stamp As DateTime
sqlUpdateDR.Parameters.Add("@time_stamp_old", time_stamp)

ERROR: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

combo 2:
Code:
Dim time_stamp as String
sqlUpdateDR.Parameters.Add("@time_stamp_old", DateTime.Parse(time_stamp))

ERROR: String reference not set to an instance of a String. Parameter name: s

combo 3:
Code:
Dim time_stamp as String
sqlUpdateDR.Parameters.Add("@time_stamp_old", SqlDbType.DateTime, 4, Format(time_stamp, "MM/dd/yyyy hh:mm:ss tt"))

OR
Code:
sqlUpdateDR.Parameters.Add("@time_stamp_old", time_stamp)

ERROR: Prepared statement '(@DR_ID int,@transfer_type nvarchar(4000),@dr_reason nvarchar(40' expects parameter @time_stamp_old, which was not supplied.

I have even made a few attempts at declaring time_stamp as SqlType.sqldatetime and working wite that, but I can't do anything with that either.

I'm running on a Windows machine, SQL 2000, and this is a ASP.NET application. The column that I'm taking the data from is of type datetime, NOT timestamp. Also, I have modified my T-SQL to "SET @sqlMessage = @time_stamp_old" and I'm still getting the errors.

Any help would be much appreciated, I'm sure there is a way to pass a datetime value back into sql for comparison.

Tetris

Reply With Quote
  #2  
Old May 11th, 2006, 01:50 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 15th Plane (12000 - 12499 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 12,025 Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 12 h 9 m 46 sec
Reputation Power: 627
A TimeStamp is not a Date/Time, so it can't be parsed as one. A TimeStamp is a unique number that gets updated every time a row gets updated.

So there's no need to "Update" the TimeStamp field, since it gets updated automatically when any field in the row is updated.

Reply With Quote
  #3  
Old May 11th, 2006, 01:55 PM
tetris tetris is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Mississauga, ON
Posts: 5 tetris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 51 sec
Reputation Power: 0
I'm only calling it time_stamp, but the field type is datetime. I'm trying to kill 2 birds with one stone, have the functionality of timestamp and date modified.

Reply With Quote
  #4  
Old May 11th, 2006, 02:01 PM
tetris tetris is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Mississauga, ON
Posts: 5 tetris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 51 sec
Reputation Power: 0
In the end it's just a question of : How do I pass a datetime parameter into my SQL code?

Reply With Quote
  #5  
Old May 11th, 2006, 03:36 PM
tetris tetris is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Mississauga, ON
Posts: 5 tetris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 51 sec
Reputation Power: 0
PROBLEM SOLVED...datatype...DdType and SqlDbType....ahhhhh two different things.

Reply With Quote
  #6  
Old March 15th, 2009, 10:57 PM
BabyAngel BabyAngel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 9 BabyAngel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 sec
Reputation Power: 0
Thumbs up Both DataSource and DataSourceID are defined on 'gridview'. Remove one definition.

i've got this problem..any1 help me solve it pls??

i've got this codes behind the designer page..

Sub BindGridView(Optional ByVal strOk As String = "", Optional ByVal searchStr As String = "")

Dim clsTickets_Obj As New clsTickets

If strOk <> "" Then
If searchStr <> "" Then
dt = clsTickets_Obj.DBSelect(Convert.ToDecimal(searchSt r))
Else
dt = clsTickets_Obj.DBSelect
End If

If dt.Rows.Count > 0 Then
ViewState("dt") = dt
End If
Else
If Not (ViewState("dt") Is Nothing) Then
dt = DirectCast(ViewState("dt"), DataTable)
End If
End If

If dt.Rows.Count > 0 Then
gd_resc.DataSource = dt
gd_resc.DataBind()
End If
End Sub




pls help me asap..thx loadz!(:

Reply With Quote
  #7  
Old March 17th, 2009, 01:53 AM
BabyAngel BabyAngel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 9 BabyAngel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 sec
Reputation Power: 0
Exclamation Input string was not in a correct format.

any1 help me solve this pls..asap..thx(:

Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
Dim tbSubj_Subject As TextBox


GridView1.EditIndex = e.NewEditIndex
BindGridView()

tbSubj_Subject = DirectCast(GridView1.Rows(e.NewEditIndex).FindCont rol("EditSubj"), TextBox)
'tbSubj_Subject.Text = dt.Rows.Find(Convert.ToString(ID.ToString))("Subject").ToString() = "laha"

End Sub

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim tbSubj_Subject As TextBox
Dim GridView1_temp As GridView

GridView1_temp = DirectCast(sender, GridView)
tbSubj_Subject = DirectCast(GridView1.Rows(e.RowIndex).FindControl( "EditSubj"), TextBox)

Dim ClsTickets_Obj As New clsTickets
ClsTickets_Obj.Subject = tbSubj_Subject.Text

If dt.Rows(e.RowIndex)("ID") = 0 Then
ClsTickets_Obj.DBInsert()
Else
ClsTickets_Obj.DBUpdate(ID)
End If

GridView1.EditIndex = -1
BindGridView("ReSelect")

End Sub


i'm tryin to edit the data and update it..bt as soon as i click on update,this error comes out..

error-
Input string was not in a correct format.
Line 65: ClsTickets_Obj.DBUpdate(ID)

Reply With Quote
  #8  
Old March 17th, 2009, 04:45 AM
Guddu's Avatar
Guddu Guddu is offline
Contributing User
ASP Free Expert (3500 - 3999 posts)
 
Join Date: Jul 2005
Location: Oxford UK
Posts: 3,873 Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level)Guddu User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 5 Days 13 h 41 m 37 sec
Reputation Power: 983
hi
i have some doubt over this code.
ClsTickets_Obj.DBUpdate(ID)
can u tell me what value u are getting for ID variable? i m not able to see in your code where u are setting value for ID ?

Hope it make some sense.
__________________
Nothing is Impossible bcoz IMPOSSIBLE itself says..
I M POSSIBLE........................
Be cool !!!!!!!!

Reply With Quote
  #9  
Old March 18th, 2009, 09:10 PM
BabyAngel BabyAngel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 9 BabyAngel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 sec
Reputation Power: 0
Question RowDataBound

Hello..i need some help on how to do this row data bound thingy..

Objective - to generate an email for the user after they hav created a ticket on their prob..

i'm able to display all the tickets but i wanna display only the informatin of that specific user.

hw do i do this??
any help much appreciated(:
thx!(:

Reply With Quote
  #10  
Old March 18th, 2009, 09:14 PM
BabyAngel BabyAngel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 9 BabyAngel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 sec
Reputation Power: 0
Smile Re: Guddu

hello Guddu,(:
its ok wid dat prob..i've solved it..(:
can u help me wid dat recent prob of mine?hw do i start abt doin dat??

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Convert string into SQL datetime value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT