 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 16th, 2004, 02:36 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
So, how do you try to retrieve that in your .NET code, if that works fine on sql query analyser. Can you post some code relavant to that?
_________________________
- Vijay G
Strive for Perfection
|
|

August 16th, 2004, 03:23 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is the code. I have bolded the select statement.
Me.SqlSelectCommand1.CommandText = "SELECT JName, JAddress, JCity, JState, JZip, JWebsite, CName, CPhone, CPhoneExtq," & _
" CEmail,convert(varchar,workdate,101) as workdate, HearingDate, AdoptionDate, RevisionDate, Status, MCommentor, " & _
"MDate, MComments, OText, OHistory, OStatus, PCIAAction, MAction FROM tbl_Jurisdi" & _
"ction"
(PLanoie- I edited out the non-relevant code because it was enormous)
|
|

August 17th, 2004, 10:29 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
That SQL looks OK. How are you using the value that is returned?
I saw a "Me.DataBind" in the code you posted (that was in the email) but we don't know yet how you actually are consuming this value from the data.
Can you post ONLY THE RELEVANT lines of code from the markup? (Please not the whole page.)
|
|

August 17th, 2004, 12:51 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
also have a look at here
http://p2p.wrox.com/topic.asp?TOPIC_ID=16185
--------------------------------------------
Mehdi.:)
|
|

August 17th, 2004, 01:05 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The details are as follows:-
I have a datagrid(first page). On selecting a record, I pass the JNAME(primary key) using the response.redirect to second page. On this second page , I am using this SELECT statement to populate my page with the values. Later in the code I append the "where clause" like this:-
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tmp_name As String
tmp_name = Request.QueryString("ID")
Me.SqlDataAdapter1.SelectCommand.CommandText &= " where JName =" & "'" & tmp_name & "'"
Me.SqlDataAdapter1.Fill(Me.DataSet11)
Me.DataBind()
End Sub
If I don't use the convert function, the workdate gets the date & time value. Workdate textbox is bound to the workdate field in the
table. Let me know if you are looking for any other specific information.
|
|

August 18th, 2004, 10:59 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok. I could move little bit ahead. This is what I found while debugging the following code in page_load method.
Dim tmpDateTime As DateTime = Now()
Me.txtWorkshopDt.Text = System.String.Format ("{0:MM/dd/yyyy}", tmpDateTime)
Me.SqlDataAdapter1.Fill(Me.DataSet11)
Me.DataBind()
I assigned today's date to a datetime variable. txtWorkshopDt was giving only date (and no Time) after System.String.Format. However after DataBind() statement, it was going back to date and time. So, instead of using bound textbox, I used unbound textbox and it retained only the date which is what I wanted. BUT, I need to use workdate(field from the table) instead of Now().I cannot use it in the page_load as it says "Name workdate is not declared". How can I use table field in the page_load method. I am so close to the solution. Please help.
I also tried declaring it in parameters as following:-
Me.SqlSelectCommand1.Parameters.Add(New SqlParameter("@WorkDate", txtWorkshopDt.Text))
Thanks
Renu
|
|

August 18th, 2004, 10:36 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Just a guess, did you try the formatting after databind()? Does that help?
_________________________
- Vijay G
Strive for Perfection
|
|

August 19th, 2004, 01:14 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Wallllaaaa! You are genius. It worked! And I used txtWorkDate.Text instead of Workdate, because it is a bound field now. I was under the impression that after you have filled the dataadapter and databound it, you cannot do anything. But, you can....Great.Thanks a lot! If your guesses are so powerful, think about your confident answers. Please see my other post also for pdf file attachment. Hope you can shed some light on that too.
Thanks
Renu
|
|

August 20th, 2004, 09:04 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Glad that it worked, nice to hear that from you. Thanks. Will take a look at your other post too, and see if I can help/guess again;).
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|
 |