|
Why are you storing the times as strings in SQL Server ? Seems to me that you can just call the split method on your string, and use int.tryparse to get out the hours, minutes, seconds.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
date.parse("18:15:15") worked for me but I'm using VS 2005. If that really won't work you might try Date.ParseExact if that's available to you. It would look something like this.
Dim t As Date = Date.ParseExact("18:15:15", "HH:mm:ss", Globalization.DateTimeFormatInfo.InvariantInfo) If that fails you could fall back to the split function which has already been suggested.
|
|
|
|
|
it still doesnt work...
maybe i havent supplied you an enough information...
here's my code... please help me...
Private ds_schedule As New DataSet()
Dim strSQL As String
Dim Connect As New SqlConnection(ConnectionString)
strSQL = "select t.tload_id,t.date_value,convert(char(10),t.start_time,14) start_time,convert(char(10),t.end_time,8) end_time,upper(r.last_name)+', '+r.first_name teacher_name,secondary_teacher_id,datediff(hh,t.start_time,t.end_time)*t.rate totla_rate,t.remarks FROM dbo.ttcpCustomizedSchedule t left outer join dbo.ResourcePersons r on r.teacher_id=t.teacher_id where t.tload_id = " & tload_id.ToString & "order by date_value"
Dim data_adapter As SqlDataAdapter
data_adapter = New SqlDataAdapter(strSQL, Connect)
data_adapter.TableMappings.Add("Table", "ttcpcustomizedschedule")
data_adapter.Fill(ds_schedule)
dtgCustomSched.SetDataBinding(ds_schedule, "ttcpcustomizedschedule")
Dim dateValue As Date
Dim startdate As Date
Dim enddate As Date
row = dtgCustomSched.CurrentRowIndex
dateValue = dtgCustomSched.Item(row, 1)
startdate = Date.ParseExact(dtgCustomSched.Item(row, 2), "HH:mm:ss", Globalization.DateTimeFormatInfo.InvariantInfo)
enddate = Date.ParseExact(dtgCustomSched.Item(row, 3), "HH:mm:ss", Globalization.DateTimeFormatInfo.InvariantInfo)
ConnectionString==my connection that is working properly
dtgCustomSched==the name of my datagrid
ds_schedule==the name of my dataset
dbo.ttcpCustomizedSchedule = table name
i think ther must be something wrong with the interaction of the dataset,datgrid,and data adapter... but i dont know what it is...
thanx!
|
|
|
|
|
What error are you getting?
What line throws the error?
(Assuming the problem is with ParseExact) Have you tried stepping into your code and verified dtgCustomSched.Item(row,2) is returning what you expect? Also note that the format of the string must be like this "03:22:12" NOT "3:22:12". If you don't use leading zero's then you need to change the formating string. "H:m:s" will allow for optional leading zeros.
|
|
|
|
|
i already check on those things.. but still, im getting the same error...
dtgCustomSched.Item(row,2) is returning what you expect? == gives me the right string with leading zeros
|
|
|
|
|
What error are you getting? == String is not recognized as a valid datetime
What line throws the error? == startdate=Date.ParseExact(dtgCustomSched.Item(row, 2), "HH:mm:ss"
i already used the "H:m:s" format but still, nothing happened.
thanx in advance!
|
|
|
|
|
Try replacing dtgCustomSched.Item(row,2) with a literal string that represents a time. Something like "12:29:01". That should certainly work. Once you've verified that try using a string variable to hold the date instead of using dtgCustomSched.Item(row,2) directly. So simply assign that value to a string and then in the ParseExact line use the string variable instead. Worth a shot I guess. If that doesn't work then go back and double and triple check the string your getting from the DB. Are you sure there aren't any other characters in it that you don't want. A space? Some sort of linefeed character or something silly like that? Basically if the string isn't 8 characters long then something isn't right. In fact try using the string.length function to verify it's length.
If you still can't get it I'd try another method. Do as christian said and use the string.split function to parse the numbers out of the string. Once you've got the individual hours, minutes, and seconds you should be able to pass those to the constructor of the date class to create your date object.
|
|
|
|
|
I would like to know how to use a button to open and existing Excel file and just view it.
|
|
|
|
|
|
hello MidwestLimey,
try out following ex..
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Try
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Open("c:\\test.xls")
excel.Visible = True
wb.Activate()
Catch ex As COMException
MessageBox.Show("Error accessing Excel: " + ex.ToString())
Catch ex As Exception
MessageBox.Show("Error: " + ex.ToString())
End Try
regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
i am using vb.net 2003.i do my project in windows application.i want to send a mail from vb.net windows application.plz help me.
|
|
|
|
|
Google it[^], for the great Sage that is google has many answers to your question.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi,
Is there any way to re-order childs of same parent. Consider example as,
A
---1
---2
---3
Using drag drop I need to change this child order as,
A
---2
---1
---3
Any luck.
Be simple and Be sample.
|
|
|
|
|
Have you looked at this[^] example? It should you what you have to do to support doing this.
|
|
|
|
|
I'm trying to give the user a chance to confirm the userdeletingrows event after the event starts,but before the datagridview row is actually deleted.
I can not seam to quit the event without deleting the row.
I can bring up a message box and run branching logic, but I'm not sure what command will prevent the row from being deleted.
Any ideas?
Kermit888
|
|
|
|
|
Hi, I have some problem while designing a windows form application in vs 2005 pro edition. The problem occure while I drag a data grid on the form and create the column for the data grid manually.
When I run an application, an error display and told me that there is a conflic name in the designer. I do not know the real error but the column that I create in the grid named: Code, Name, Strength, Form...
When I return to the designer I found my form disappear and just display some error in the designer page. I do not know how to fix it while vs 2005 do not allow me to see my form and change the property of the control.
On the other hand, VS should inform me if there name of the column is matched with the keyword using in VS. I really feel disappoint while I challenge this problem and could not find the solution.
Does anyone have any idea about this problem? Please help me to find the solution.
Thank in Advance!!!
|
|
|
|
|
Post the error.
Tom Wright
tawright915@gmail.com
|
|
|
|
|
It because you used "Name" as column name
Try change the column name "Name" to example "Customer Name" or other name
|
|
|
|
|
Thank you very much for your help. So, how could I prevent in the future to avoid duplicate keyword with vb.net 2005?
|
|
|
|
|
I think you should read or search about vb.net keyword
GoodID
|
|
|
|
|
Thank you very much for your solution.
|
|
|
|
|
Hi, I used visual studio .net 2005 standard edition in my laptop. Vs 2005 standard do not have crystal report integrated with. So I plan to purchase crystal report v11 pro edition.
My question is, if i install crystal report v11 pro edition on my laptop, could I design a report in crystal report and integrate it with my application design in vs.net 2005 standard edition?
Thank in advance!!!
|
|
|
|
|
hi, anyone can help me figure out how to read data from a text file like this:
10980012907200228082002
and extract the data according to this kind of format:
Record type 1
TY-RECORD PIC (1).
ID-PARTICIPANT PIC (6).
DT-START PIC (8).
DT-END PIC (8).
the data can be read as ty-record = 1, id-participant = 98001, dt-start = 29072002, and dt-end = 28082002. i would want the program to extract the data and display them in a table according to their respective fields:
TY-RECORD ID-PARTICIPANT DT-START DT-END
1 098001 29072002 28082002
and to save them in an excel format. I have plenty of record types (0 - 9) and need to display them in separate tables.
does anyone has a source code for this? or at least somebody pls guide me to figure out ways to create the program.
many thanks!
|
|
|
|
|
you can read each line and replace the space with a comma, and Excel will just open it. To have multiple tables, you need to look into the visual studio tools for office.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi all
Can any one help me about how (Cut and paste files and folders from clipboard )
and i will be very thankful to everyone help me
|
|
|
|