|
Could you give an example of what your meaning? I am not sure what you are meaning of using delegates.
Thanks for your quick reply
|
|
|
|
|
Do you know what a delegate is ? Have you tried using google to find out ?
A delegate is a variable which represents a function definition. It can be assigned to any function that fits the definition, which means that one form can define a method used to pass data as a delegate, and an instance of that delegate, and another form can define the function that the instance is assigned to. So, form1 can call a method which is within form2, and pass any data it likes.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi,
anyone know how to search the date by "dd/mm/yyyy" in sql query!
my code is :
Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "#
and data type i set it to date/time!
The result is not efficient to select the month!
Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006......
Please help!
|
|
|
|
|
I thnk DATEPART is what you need, perhaps.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Most likely due to the date format that you are using. The database is probably expecting the format "MM/dd/yyyy".
You should use an unambigous date format like ISO 8601 ("yyyy-MM-dd"), or better yet, parameterised queries.
---
b { font-weight: normal; }
|
|
|
|
|
use "yyyy-MM-dd" + " 00:00:00 Between "yyyy-MM-dd" + " 23:59:59 "
Format
Ravikumar
[Coimbatore]
|
|
|
|
|
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.
|
|
|
|