|
This is a piece of code you can use to convert data:
SET DATEFORMAT dmy
DECLARE @datevar datetime
SET @datevar = '31/12/1998'
SELECT @datevar
And the result are:
1998-12-31 00:00:00.000
Hope this helps!
-- modified at 9:07 Wednesday 6th December, 2006
|
|
|
|
|
good day everyone, once again i need your help...("i do always need your help...")
how to clear textbox control?
i only do this manually like this : textbox1.text = ""
my problem is, if i will have 10 more textbox in my form it will consume more time to do the same thing...
anyone can help me, how to solve my problem of difficulties?....
i know its to simple for you guys... pls i need your help once again... thank you...
Special Thanks to Sir Chris.. for giving your ideas...
nothing is impossible.....
|
|
|
|
|
momooomooomomo wrote: my problem is, if i will have 10 more textbox in my form it will consume more time to do the same thing...
It doesn't take that long, just change the TextBox value.
|
|
|
|
|
thats good and i appreciat your effort... but my problem is how to code on how to clear textbox without knowing that you have 10 or more textbox in a form?... that idea is great but i need more technical answer coz i already done this one textbox1.text = ""...
nothing is impossible.....
|
|
|
|
|
The only other thing I can think of is setting a Property Binding to each textbox and changing the property binding. That may not be how you want to do it, but I'm not sure how else too.
Is the user going to be adding more textboxes to your form?
|
|
|
|
|
hi,
this code snippet will clear all textboxes present on the windows form
Dim ctrl As New Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is System.Windows.Forms.TextBox Then
ctrl.Text = ""
End If
Next
Regards,
Kapil Thakur
(Where's there is Kapil , there is a way) - thakur.kapil@gmail.com
|
|
|
|
|
I need my program to go intop a datatable and grab 2 values and assign them to 2 different variables. BUT i need the program to grab the 2 cell values base upon another cell value. so, Basically i need to search the database and pull the row of data related to the criteria that i enter for column 1, and assign col2 and col3 to seperate varibles.
Thanx for the ear
Joshua
|
|
|
|
|
Yes when I my form layed out with all my buttons, text, comboboxes, etc... and use the Fontdialog to change the type, style and size it always makes the controls overlap others. I have looked for a way to make the form, controls, etc... to resize to handle the larger font size and or style to keep the same look, but I can't. Does anyone have a way to fix this?
|
|
|
|
|
I'm trying to get a VB report to read its data from a dataset but when the report prints it is blank.
First I created a dataset in the project. I right clicked on the dataset designer and created a table with one column in it. Then I created a VB report and dragged the column from the datasources window onto the report. Next I created a form and dropped a reportviewer onto it and attached the report to reportviewer. In the load of this form I put the following code in to populate the dataset.
Me.SalesOrderDataSet = New Inventory.SalesOrderDataSet
Me.SalesOrderDataSet.DataSetName = "SalesOrderDataSet"
Me.SalesOrderDataSet.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema
Dim newrow0 As DataRow
newrow0 = SalesOrderDataSet.SalesOrder.NewRow
newrow0.Item("company") = "Arlington"
SalesOrderDataSet.SalesOrder.Rows.Add(newrow0)
This code is supposed to populate the dataset for the report but why is the report not displaying this data?
|
|
|
|
|
:-DI am 6years-VB6 programmer.
I newly stepped into vb.net
I want to set up dataset with a datagrid
Although I used different ways I couldn't succeeded.
I just want a small, simple database connection on a Form.
Thanx
gorenekli
|
|
|
|
|
Hi, this is an excerpt from one of my recent projects
<br />
Dim connection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))<br />
Dim command As New SqlCommand("Select * from course inner join Faculty on course.CMgr = faculty.staffID", connection)<br />
Dim dataAdapter As New SqlDataAdapter(command)<br />
Dim result As New DataSet<br />
connection.Open()<br />
dataAdapter.Fill(result, "Course")<br />
connection.Close()<br />
addCourseGrid.DataSource = result<br />
addCourseGrid.DataBind()
I hope it helps!
|
|
|
|
|
I wrote a small SQL wraper here:
http://www.codeproject.com/useritems/winSQLite.asp[^]
it makes life easyer...it was writen for 2005, but I think the only thing that needs to be changed to work with 2003 would be a small part in the conversion of a datareader to a dataset.
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
|
Hi all,
I have recently been trying to find the best method of determining how many lines a text file contains. The main issue has been that the files I am working with are usually above 100Mb and are located on network shares of varying connected speeds and reliability.
Just thought I would share my experiences and see if anyone else had any ideas or recomendations
So far I have tried the following:
1) Looping through the file using the IO.TextReader (both readline, and readtoend methods) but this uses a whole heap of memmory and is very very slow. It is also hard to implement a progress indicater.
<br />
Private Function LineCount(FileName) As Long<br />
Dim TX As IO.TextReader = IO.File.OpenText(FileName)<br />
<br />
Dim ALine As String = TX.ReadLine<br />
Dim Counter As Long = 0<br />
<br />
Do While Not ALine Is Nothing<br />
Counter += 1<br />
ALine = TX.ReadLine<br />
Loop<br />
<br />
TX.Close()<br />
<br />
Return Counter<br />
<br />
End Function<br />
2) Looping through the file using the IO.FileStream byte at a time. This seems to perform better than the textreader method but is still a very slow option. It however does provide an easy way to show the progress by calculating the bytes done against the total file size
<br />
Public Function LineCount(ByVal fileName As String) As Long<br />
<br />
Dim lineBuffer As Byte()<br />
lineBuffer = New Byte(4196 - 1) {}<br />
Dim LineCount As Long<br />
Dim FI As New IO.FileInfo(fileName)<br />
Dim FileSize As Long = FI.Length<br />
Dim BytesProcessed As Long = 0<br />
Dim BufferRead As Integer = 0<br />
Dim x As Integer = 0<br />
LineCount = 0<br />
<br />
<br />
Dim FS As New FileStream(fi.FullName, FileMode.Open, FileAccess.Read, _<br />
FileShare.Read, lineBuffer.Length)<br />
<br />
Do While BytesProcessed < FileSize<br />
Try<br />
BufferRead = FS.Read(lineBuffer, 0, lineBuffer.Length)<br />
<br />
If BufferRead > 0 Then<br />
For x = 0 To (BufferRead - 1)<br />
If lineBuffer(x) = 13 Then<br />
LineCount += 1<br />
End If<br />
<br />
' Evaluate Percent done here i.e Percentdone = CInt((BytesProcessed / FileSize) * 100)<br />
<br />
BytesProcessed += 1<br />
Next<br />
End If<br />
Loop<br />
<br />
FS.Close()<br />
Return LineCount<br />
<br />
End Function<br />
3) looping through a percentage of the file using the IO.FileStream byte at a time and estimating the number of lines based on the overall file length and the average line byte length. This was fairly fast but produced varying degrees of accuracy as the line lengths are mor often than not irregular.
<br />
Public Function LineCount(ByVal fileName As String, ByVal PercentageRead as Integer) As Long<br />
<br />
Dim lineBuffer As Byte()<br />
lineBuffer = New Byte(4196 - 1) {}<br />
Dim LineCount As Long<br />
Dim FI As New IO.FileInfo(fileName)<br />
Dim FileSize As Long = FI.Length<br />
Dim BytesProcessed As Long = 0<br />
Dim BufferRead As Integer = 0<br />
Dim x As Integer = 0<br />
Dim FileSizePercentage As Integer = Cint((FileSize / 100) * PercentageRead)<br />
LineCount = 0<br />
<br />
<br />
Dim FS As New FileStream(fi.FullName, FileMode.Open, FileAccess.Read, _<br />
FileShare.Read, lineBuffer.Length)<br />
<br />
Do While BytesProcessed < FileSizePercentage<br />
Try<br />
BufferRead = FS.Read(lineBuffer, 0, lineBuffer.Length)<br />
<br />
If BufferRead > 0 Then<br />
For x = 0 To (BufferRead - 1)<br />
If lineBuffer(x) = 13 Then<br />
LineCount += 1<br />
End If<br />
<br />
' Evaluate Percent done here i.e Percentdone = CInt((BytesProcessed / FileSizePercentage) * 100)<br />
<br />
BytesProcessed += 1<br />
Next<br />
End If<br />
Loop<br />
<br />
FS.Close()<br />
<br />
Return Clng((LineCount / FileSizePercentage) * 100)<br />
<br />
End Function<br />
4) Using LogParser Interfaces collection shipped with MS Logparser 2.2. This seems
to be the fastest method but will only work for files with a line count within the Int32 range. And again has no way to determine the percentage done.
<br />
Public Function LineCount(ByVal fileName As String) As Integer<br />
<br />
Dim InputClass As New MSUtil.COMTextLineInputContextClass<br />
Dim LogParserClass As New MSUtil.LogQueryClass<br />
Dim IRs As MSUtil.ILogRecordset <br />
Dim QueryString As String = "SELECT COUNT(Text) FROM '" & fileName & "'"<br />
<br />
InputClass.splitLongLines = False <br />
<br />
IRs = LogParserClass.Execute(QueryString, InputClass)<br />
Return IRs.inputUnitsProcessed<br />
<br />
End Function<br />
Ideas and thoughts appreciated
|
|
|
|
|
I'm not completely sure but I was under in the impression that when using IO.TextReader and IO.FileStream Classes is like opening a connection to the document and reading it from it original location. Would creating a temp copy of the file for processing help your performance?
milkyjoe wrote: above 100Mb and are located on network shares of varying connected speeds and reliability
Dim dtTimeStamp As String = Date.Now.ToString.Replace("/", "-")<br />
Dim tempFileDir As String = IO.Directory.GetCurrentDirectory & "\temp"<br />
Dim tempPath As String = tempFileDir & "\" & dtTimeStamp.Replace(":", "")<br />
IO.File.Copy(remoteFileLocation, tempPath)
Do all the processing then kill the file when your collecting or garbage.
|
|
|
|
|
Hi AreJay, thanks for the reply.
I had thought about trying this but have not as yet. If I remember correctly there is also a bytestream method for copying files. I am now wondering if I can read the file as I copy it. I will give it a go and let you know how I get on.
|
|
|
|
|
I'm not sure if this is the correct area, forgive me if it is not!
I have this datagrid that is called deleteCourseGrid and it has a template column. I put a checkbox inside and its ID is deleteCheck.
I also have a confirm button that runs the code below.
The problem is, somehow, it does not detect that a box is checked. I tried checking each individual rows and cb.checked is always false.
Am I doing something wrong?
Thanks for help in advance!
Dim connection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))<br />
Dim command As New SqlCommand("delete from course where courseID = @courseID", connection)<br />
Dim i As Integer = 0<br />
Dim cb As CheckBox<br />
Dim courseID As String<br />
cb = deleteCourseGrid.Items(i).FindControl("deleteCheck")<br />
For i = 0 To deleteCourseGrid.Items.Count - 1<br />
If cb.Checked = True Then<br />
courseID = deleteCourseGrid.Items(i).Cells(0).Text<br />
command.Parameters.Add("@courseID", courseID)<br />
connection.Open()<br />
command.ExecuteNonQuery()<br />
connection.Close()<br />
End If<br />
Next<br />
Response.Redirect("updated.aspx")
|
|
|
|
|
try treating cells in that column as bools
<br />
If row.item("deleteCheck") then<br />
Delete<br />
End if<br />
|
|
|
|
|
Hi! Thanks for the help.
But I'm really not sure what you mean. Could you elaborate?
Thanks!
|
|
|
|
|
well your normal textbox data column in the grid, displays all strings and numbers as text. It works the same for boolean columns. A DataGridBoolColumn will display true as checked, false as unchecked. So whatever column on your datatable is mapped to this DataGridBoolColumn will contain the true or false that is shown in the datagrid column.
If you had a datatable (Two columns -> Name, Smoker) where smoker would be mapped to the DataGridBoolColumn, in each row in the table, a boolean would appear in the column smoker with resepct to the checked state of the textbox on the datagrid.
Hope that helps.
|
|
|
|
|
Thanks Kevin.
I think understand the logic behind your explanation, however I fail to find anything that relates DataGridBoolColumn in Visual Studio 2003.
Is there something that I'm missing?
What I'm trying to do is to allow the administrator to tick the courses that he wants to delete and then when he clicks the confirm button, the code scrolls through, if it's ticked, it sends the SQL command and deletes it.
I'm sorry for troubling you =/
|
|
|
|
|
ok This is how I would do that. Lets say you have a datatable (courseTable) with one column (A course ID).
First add a second column to the table
<br />
courseTable.columns.add(new dataColumn("Delete"))<br />
Setup the tablestyle for the bool column
<br />
Dim style As New DataGridTableStyle<br />
style.GridColumnStyles.Clear()<br />
style.MappingName = courseTable.TableName<br />
<br />
Dim col As New DataGridBoolColumn<br />
col.MappingName = "Delete"<br />
col.HeaderText = "Delete"<br />
col.AllowNull = False<br />
style.GridColumnStyles.Add(col)<br />
<br />
DataGrid1.TableStyles.Add(style)<br />
DataGrid1.DataSource = courseTable<br />
now you have the right setup for the bool column, just display it by adding rows to the datatable somehow from the database.
so in your confirm button routine just check for deletes
<br />
For Each row As DataRow In courseTable.Rows<br />
If row.Item("Delete") Then<br />
'This row was ticked so perform a delete<br />
End If<br />
Next<br />
That should do it for you
|
|
|
|
|
I'm trying this out and I have a strong feeling that it will help with my problem.
However, I am stuck at trying to dim a new DataGridTableStyle. Is this not available in The .Net 1.1 framework or something? Visual Studio 2003 says that Type DataGridTableStyle is not defined.
I tried reading http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx#S6 and it talks about DataGridTableStyle, yet visual studio does not seem to recognise this.
What should I do? And a million thanks for your many replies!
|
|
|
|
|
DataGridTableStyle is valid in windows application.
but you are working in web applications that why you are getting it and it is giving errors.
anyways next time post your questions in asp.net forum....you have currently posted this question in vb.net ..............thats why the person has misunderstood the scenario and he has given this answer.....anyways it happens..
hope you have found solution to your problem.
Regards,
Kapil Thakur
(Where's there is Kapil , there is a way) - thakur.kapil@gmail.com
|
|
|
|
|
hi,
you are currently taking the checked value as string. Instead of it, take it as a boolean variable.
i m using your code and the changes are reflected in BOLD text.
Dim cb As BOOLEAN
Dim courseID As boolean
cb = CTYPE(deleteCourseGrid.Items(i).FindControl("deleteCheck"), CHECKBOX).CHECKED
For i = 0 To deleteCourseGrid.Items.Count - 1
IF cb = TRUE THEN
courseID = deleteCourseGrid.Items(i).Cells(0).Text
command.Parameters.Add("@courseID", courseID)
connection.Open()
command.ExecuteNonQuery()
connection.Close()
End If
use this and your code will work fine.
ALSO check that you are reloading the datagrid on page_load
Regards,
Kapil Thakur
(Where's there is Kapil , there is a way) - thakur.kapil@gmail.com
|
|
|
|
|
Hi!
Thanks for the help!!
I tried your way, however it does not work.
I've been stepping the program through and the problem lies with the fact that it is somehow ignoring boxes that are checked.
So it keeps looping to If cb = true then and then skipping the entire code within and just stepping over to End If
This is really confusing =/
|
|
|
|