|
To CodeProject,
This is regarding a project that I'm trying to implement - quick chronological file opener script with retrieving 'FileDate' and 'ObjFilePath' and sorting its data into application calendar menu with qick links to exisiting files.
Plese give some suggestions on file date and time attributes inserting into form style widget
Regards, Nik
|
|
|
|
|
Ive read this a dozen times and I can't figure out what your'e trying to say. Don't bother repeateding what you've already said. Break the problem down into smaller parts and describe each of them.
If you can't communicate what you what to do with us, you'll find it impossible to describe how to do it to a computer which is far more picky.
|
|
|
|
|
Hello, the script should list files within directory and date file attributes than it should deliver data array into calendar links widget for quick acces to files by creation date and so, here is the working script that need modification
<pre lang="Javascript">
<html>
<Head>
<Title>HTA Script</Title>
<Style>
Body {Background-Color: CornSilk}
/* Sortable tables */
table.sortable thead {
background-color:#eee;
color:#666666;
font-weight: bold;
cursor: pointer;
}
</Style>
<HTA:Application
Caption = Yes
Border = Thick
ShowInTaskBar = No
MaximizeButton = Yes
MinimizeButton = Yes>
<Script Language = VBScript>
Dim Wsh,WScript
Set Wsh = CreateObject("WScript.Shell")
Sub WindowsLoads
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\")
If objFolder Is Nothing Then
Exit Sub
Else
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
End If
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(objPath)
For each objFile in objFolder.Files
FileDate = FormatDateTime(objFile.DateLastModified,2)
If objFolder.Files.Count > 0 Then
Window.Document.Title = "Information For " & objPath
chbox = objFile.Path
strHtml = strHtml & "<tr><td><a href=" & objFile.Path & " name=chbox target=_blank>" & objFile.Name & "</a></td><td width=30> </td><td>" & FileDate & "</td></tr>"
DataArea.InnerHtml = "<table><tr><td> </td><td> </td><td> </td></tr>" & strHtml & "</table>"
End If
Next
End Sub
</script>
</head>
<Body onLoad = "WindowsLoads">
<p><h3 align = center><font color='Orange'>File List</font></h3>
</p>
<Span Id = "DataArea"></Span></Body><Div Align = "Center">
<P>-File List-</P>
</Body>
</html></pre>
-- modified 4-Jun-13 18:07pm.
|
|
|
|
|
n381 wrote: deliver data array into calendar links widget
What in Hell is a "calendar links widget"?!?! We STILL don't have a clue as to what you're talking about.
|
|
|
|
|
Let's say it is menu created of files date attributes, sorted as calendar (widget) with links to files,
so it can be used for quick access to files selecting creation date link pointers istead of link text.
Nik
|
|
|
|
|
I STILL can't figure out what you're talking about, "sorted as calendar (widget)".
Have a nice life!
|
|
|
|
|
Okay,
here is the snapshot of two applications combined : file list and calendar widget
[url=http://postimage.org/][img=http://s8.postimg.org/rs9zsz3md/vbs_link_calendar_widget.jpg][/url]
[url=http://postimage.org/app.php]windows print screen[/url]
http://s8.postimg.org/rs9zsz3md/vbs_link_calendar_widget.jpg
Regards
|
|
|
|
|
So it searches for files somewhere and places links to them into a calendar-like control(.NET MonthCalendar , perhaps?), so that the date the link is displayed on is the date of the last edit.
At least that was what I understood it as.
|
|
|
|
|
Thank you for replying,
yes it is similar kind of application but simplified and should work with retrieving 'FileDate' and 'ObjFilePath' form file attached and sorting its data into application calendar menu with quick links to exisiting files,
please assist with your suggestions
<pre lang="vb">
<HTA:Application
Caption = Yes
Border = Thick
ShowInTaskBar = No
MaximizeButton = Yes
MinimizeButton = Yes>
<Script Language = VBScript>
Dim Wsh,WScript
Set Wsh = CreateObject("WScript.Shell")
Sub WindowsLoads
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\")
If objFolder Is Nothing Then
Exit Sub
Else
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
End If
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(objPath)
For each objFile in objFolder.Files
FileDate = FormatDateTime(objFile.DateLastModified,2)
If objFolder.Files.Count > 0 Then
Window.Document.Title = "Information For " & objPath
chbox = objFile.Path
strHtml = strHtml & "<tr><td><a href=" & objFile.Path & " name=chbox target=_blank>" & objFile.Name & "</a></td><td width=30 class=sorttable_nosort> </td><td>" & FileDate & "</td></tr>"
DataArea.InnerHtml = "<table><tr><td> </td><td width=30> </td><td> </td></tr>" & strHtml & "</table>"
//The output string results to be processed into calendar widget with link to files//
End If
Next
End Sub
</script>
</head>
<Body onLoad = "WindowsLoads">
<p><h3 align = center><font color='Orange'>File List</font></h3>
</p>
<Span Id = "DataArea"></Span></Body><Div Align = "Center">
<P>-File List-</P>
</pre>
|
|
|
|
|
hello guys i have doing some project and since i have new for vb.net 2010. my project is coded in vb.net 2010 and ms access 2007 mdb database. i have DocId, description, date and other fileds in the table.. my querry works for all but. i can't add all characters except integers in the database column DocId. it accepts only integer values. so how can i insert characters in the DocId filed. here is the detail
tables: DocId======Textbox name RefferencNoTxt.Text
Table name = EraDms
database name= data
cmd.CommandText = "INSERT INTO EraDms(DocId,Description,Address,NoOfPages, SendOrReceived, SentDate,ReceivedDate,ForwardedWorkingUnit,Attachements,ForwardedDate,ReceivedBy,DocPath) " & _
" VALUES(" & Me.RefferencNoTxt.Text.ToString & ",'" & Me.DescriptionTextBox.Text & "','" & Me.AddressTextBox.Text & "','" & Me.NoOfPagesTextBox.Text & "','" & Me.SendOrReceievedComboBox.Text & "','" & _
Me.SentDateTextBox.Text & "','" & Me.receivedDate.Text & "','" & Me.ForwardedWorkingUnitTextBox.Text & "','" & Me.AttachementsTextBox.Text & "','" & Me.TextBox6.Text & "','" & Me.ReceivedByTextBox.Text & "','" & Me.DocPathTextBox.Text & "')"
cmd.ExecuteNonQuery()
MessageBox.Show("File Upload Successfull", "ERA-DMS-File Uploader", MessageBoxButtons.OK, MessageBoxIcon.Information)
RefreshData()
cnn.Close()
Else
cmd.CommandText = "UPDATE Eradms " & _
" SET DocId=" & Me.RefferencNoTxt.Text.ToString & _
", Description='" & Me.DescriptionTextBox.Text & "'" & _
", Address='" & Me.AddressTextBox.Text & "'" & _
", NoOfPages='" & Me.NoOfPagesTextBox.Text & "'" & _
", SendOrReceived='" & Me.SendOrReceievedComboBox.Text & "'" & _
", SentDate='" & Me.SentDateTextBox.Text & "'" & _
", ReceivedDate='" & Me.TextBox1.Text & "'" & _
", ForwardedWorkingUnit='" & Me.ForwardedWorkingUnitTextBox.Text & "'" & _
", Attachements='" & Me.AttachementsTextBox.Text & "'" & _
",ForwardedDate ='" & Me.TextBox6.Text & "'" & _
",ReceivedBy ='" & Me.ReceivedByTextBox.Text & "'" & _
",DocPath='" & Me.DocPathTextBox.Text & "'" &
" WHERE DocId=" & Me.RefferencNoTxt.Text.ToString
cmd.ExecuteNonQuery()
RefreshData()
Private Sub RefreshData()
Try
If Not cnn.State = ConnectionState.Open Then
'open connection
cnn.Open()
End If
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM EraDms", cnn)
Dim dt As New DataTable
'fill data to datatable
da.Fill(dt)
'offer data in data table into datagridview
Catch ex As OleDb.OleDbException
End Try
End Sub
best regards
|
|
|
|
|
Change the definition of DocID from Integer to Text in the database.
|
|
|
|
|
DocId data type is text in my database
|
|
|
|
|
What is the actual definition for DocId in your database schema? Also why are you calling ToString on the Me.RefferencNoTxt.Text object; is it not already text?
Use the best guess
|
|
|
|
|
Beiniam wrote: i can't add all characters except integers in the database column DocId. it accepts only integer values. so how can i insert characters in the DocId filed.
From that it makes me ask the question is the column type numeric? (integer, decimal etc.)
you will need to convert RefferencNoTxt.Text to the correct numeric type that your database needs.
i.e.
dim value as integer = Convert.ToInt32(RefferencNoTxt.Text)
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Your code is a classic example of SQL Injection[^]. One mis-placed ' in a text box, and your entire database could be corrupted.
Change the code to use parametereized queries instead:
cmd.CommandText = _
"INSERT INTO EraDms(DocId, Description, Address, NoOfPages, SendOrReceived, SentDate, ReceivedDate, ForwardedWorkingUnit, Attachements, ForwardedDate, ReceivedBy, DocPath) " & _
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
cmd.Parameters.AddWithValue("@p0", Me.RefferencNoTxt.Text)
cmd.Parameters.AddWithValue("@p1", Me.DescriptionTextBox.Text)
cmd.Parameters.AddWithValue("@p2", Me.AddressTextBox.Text)
cmd.Parameters.AddWithValue("@p3", Me.NoOfPagesTextBox.Text)
cmd.Parameters.AddWithValue("@p4", Me.SendOrReceievedComboBox.Text)
cmd.Parameters.AddWithValue("@p5", Me.SentDateTextBox.Text)
cmd.Parameters.AddWithValue("@p6", Me.receivedDate.Text)
cmd.Parameters.AddWithValue("@p7", Me.ForwardedWorkingUnitTextBox.Text)
cmd.Parameters.AddWithValue("@p8", Me.AttachementsTextBox.Text)
cmd.Parameters.AddWithValue("@p9", Me.TextBox6.Text)
cmd.Parameters.AddWithValue("@p10", Me.ReceivedByTextBox.Text)
cmd.Parameters.AddWithValue("@p11", Me.DocPathTextBox.Text)
And:
cmd.CommandText = _
"UPDATE Eradms " & _
" SET Description = ?, " & _
" Address = ?, " & _
" NoOfPages = ?, " & _
" SendOrReceived = ?, " & _
" SentDate = ?, " & _
" ReceivedDate = ?, " & _
" ForwardedWorkingUnit = ?, " & _
" Attachements = ?, " & _
" ForwardedDate = ?, " & _
" ReceivedBy = ?, " & _
" DocPath = ? " & _
" WHERE DocId = ?"
cmd.Parameters.AddWithValue("@p0", Me.DescriptionTextBox.Text)
cmd.Parameters.AddWithValue("@p1", Me.AddressTextBox.Text)
cmd.Parameters.AddWithValue("@p2", Me.NoOfPagesTextBox.Text)
cmd.Parameters.AddWithValue("@p3", Me.SendOrReceievedComboBox.Text)
cmd.Parameters.AddWithValue("@p4", Me.SentDateTextBox.Text)
cmd.Parameters.AddWithValue("@p5", Me.receivedDate.Text)
cmd.Parameters.AddWithValue("@p6", Me.ForwardedWorkingUnitTextBox.Text)
cmd.Parameters.AddWithValue("@p7", Me.AttachementsTextBox.Text)
cmd.Parameters.AddWithValue("@p8", Me.TextBox6.Text)
cmd.Parameters.AddWithValue("@p9", Me.ReceivedByTextBox.Text)
cmd.Parameters.AddWithValue("@p10", Me.DocPathTextBox.Text)
cmd.Parameters.AddWithValue("@p11", Me.RefferencNoTxt.Text)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank you a lot
Richard Deeming eming for your help. it works
|
|
|
|
|
I'm trying to create a utility to perform a mass update of our Active Directory and all I get is the error, "Server is unwilling to process request."
Below is my code:
Dim de As New DirectoryEntry("GC://DC=us,DC=myCompany,DC=com", "myDomain\MyAdminUsername", "myPassword")
Dim ds As New DirectorySearcher(de)
ds.PropertiesToLoad.Add("department")
ds.SearchScope = SearchScope.Subtree
Dim ue As New DirectoryEntry
ds.Filter = String.Format("(SAMAccountName={0})", Me.tboxUserName.Text)
Try
ue = ds.FindOne.GetDirectoryEntry
For Each sproperty As String In ue.Properties.PropertyNames
debug.print(String.Format("{0}{1} : {2} ", System.Environment.NewLine, sproperty, ue.Properties(sproperty)(0)))
Next
If (ue.Properties.Contains("department")) Then
ue.Properties("department").Value = "IT"
Else
ue.Properties("department").Add("IT")
End If
ue.CommitChanges()
ue.RefreshCache()
ue.Close()
Catch ex As Exception
debug.print (ex.Message)
End Try
The code seems to connect to the LDAP server and retrieve the correct user because I can see valid data being displayed from the ue.Properties.PropertyNames collection.
The error is thrown on the "CommitChanges()" line.
BTW: This demo program is a WinForms .NET 4.0 applicaiton
I have tried it passing no credentials and passing valid domain credentials and I get the same " ... unwilling to process request." error.
What am I doing wrong?
|
|
|
|
|
According to http://forums.asp.net/t/1809557.aspx/1[^], the problem arises by using the wrong protocol:
Dim de As New DirectoryEntry("GC://DC=us,DC=myCompany,DC=com", "myDomain\MyAdminUsername", "myPassword")
replace that with
Dim de As New DirectoryEntry(@"LDAP:\\DC=us,DC=myCompany,DC=com", "myDomain\MyAdminUsername", "myPassword")
|
|
|
|
|
Thank you so much. My program is now working.
I've been trying so many combinations that I must have overlooked the obvious.
|
|
|
|
|
This question is a new post prompted by my other thread, "The old DoEvents and UserControls". I created a separate thread here, since it is branching off from the old discussion.
In the other thread, it was looking like converting code from supporting DoEvents, to supporting threading might be a big rewrite. But now I am not so sure. I downloaded an example Pause/Resume Thread program from online and that program had a separate class that was threaded. It then communicated to the main form via a delegate.
But I wanted to find out if it was possible to do threading of a procedure that was NOT in a separate class...But one residing in the main form's class, like any other sub. The reason this was important to me, was to cut down on the amount of code rewriting by keeping my existing code in place, and merely adding on additional code to thread one of those main form procedures. My revision to that original threading example seems to say, "yes", to that question. Here is my version of that little demo. It simply runs a counter that counts from 1 to whatever, and when the thread is suspended, the counter halts, until resumed. Since I am new to threading, is there anything wrong with this idea that could end up biting me in the rear?
Here is the code:
Imports System.Threading
Imports System
Public Class Form1
Private Delegate Sub DisplayValueDelegateType(ByVal txt _
As String)
Private m_DisplayValueDelegate As DisplayValueDelegateType
Private m_Thread As Thread
Public Value As Integer = 0
Public Sub DisplayValue(ByVal txt As String)
txtResults.Text = txt
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim new_counter As New Counter(Me, my_number:=1)
m_Thread = New Thread(AddressOf new_counter.Runno)
m_Thread.IsBackground = True
m_Thread.Start()
Button1.Enabled = False
Button2.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
If (m_Thread.ThreadState And ThreadState.Unstarted) _
<> 0 Then
m_Thread.Start()
Else
m_Thread.Resume()
End If
Button1.Enabled = False
Button2.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
Debug.WriteLine("Suspending thread")
m_Thread.Suspend()
Button1.Enabled = True
Button2.Enabled = False
End Sub
Public Sub DoSomething(ByVal m_MyForm As Form1, _
ByVal m_DisplayValueDelegate _
As Object)
For loopo = 1 To 10000000
Thread.Sleep(3000)
SyncLock m_MyForm
m_MyForm.Value = m_MyForm.Value + 1
If m_MyForm.InvokeRequired() Then
m_MyForm.Invoke(m_DisplayValueDelegate, _
Str(m_MyForm.Value))
End If
End SyncLock
Next loopo
End Sub
Private Sub Quit_cmd_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Quit_cmd.Click
End
End Sub
End Class
Public Class Counter
Private m_MyForm As Form1
Private Delegate Sub DisplayValueDelegateType( _
ByVal txt As String)
Private m_DisplayValueDelegate As DisplayValueDelegateType
Private m_Number As Integer
Public Sub New(ByVal my_form As Form1, _
ByVal my_number As Integer)
m_MyForm = my_form
m_Number = my_number
m_DisplayValueDelegate = AddressOf _
m_MyForm.DisplayValue
End Sub
Public Sub Runno()
Try
Call Form1.DoSomething(m_MyForm, m_DisplayValueDelegate)
Catch ex As Exception
Debug.WriteLine("Unexpected error in thread " & _
m_Number & vbCrLf & ex.Message)
End Try
End Sub
End Class
|
|
|
|
|
treddie wrote: I wanted to find out if it was possible to do threading of a procedure that was NOT in a separate class
No need to test. Yes, you can thread just about any code you want. A form is just a class, like any other.
treddie wrote: The reason this was important to me, was to cut down on the amount of code
rewriting by keeping my existing code in place, and merely adding on additional
code to thread one of those main form procedures.
Wrong approach. If your going to go through the trouble of threading the code, scrap what you have and do it write instead of trying to Frankenstein a solution together.
|
|
|
|
|
But the example program I showed does basically what I'm suggesting. So it doesn't SEEM like a kludge. Especially since all I basically have is one procedure that I need to thread, and everything else is called from it sequentially. So from a performance point of view, it all has to work sequentially anyway, so my only benefit from threading is to have the ability to pause execution at will, which was the primary reason to begin with. Is that a reasonable enough reason for doing it that way? I don't see any future versions of this program gaining any other benefits from threading.
|
|
|
|
|
Hey guys,
I want to connect my VB.NET application to the data saved on my webserver's mysql database. Can you please tell me, is it possible or not? Can you give me any hint for further coading? Where should i look for help in this regard?
Or should I consider other language for this pupose?
[Project Details:]
I want users to fill their info on online php form, this info get saved in mysql database. Now i want to insert this info in the .net application's database installed on client's computer.
|
|
|
|
|
Hi again.
I am curious about a problem I am having with DoEvents. Now, I know DoEvents() is old school, and was only included in vb6 because vb6 did not support threading, at least not without a lot of difficulty. But the problem I have, is that I have ported a vb6 program over to vb.Net and there were a fair amount of DoEvents() lines due to a bunch of loops. These DoEvents lines were necessary because I had a Pause button that needs to stop execution when the user desires it.
This worked OK in .Net, too...Until I included a TreeView usercontrol. Now, a fair amount of time is spent in the usercontrol since as the program scans folders, the TreeView is constantly updating to show the progress. In itself, that is a very inefficient way to show progress due to the amount of time processing the TreeView updates. But it looks rather cool as it progresses and I want to keep that look. The problem is that, I know that threading is the way to handle interruption of processing, but on the other hand, I just want this thing running as quickly as possible with the DoEvents lines...I can switch over to threading at some later date.
But no matter where I put the DoEvents lines, they do not let the Pause button Click event to fire. My question is, does entering a usercontrol cause DoEvents in the stack to get cleared out? Or does it simply disregard any DoEvents lines altogether, whether they are inside the user control or not?
Many thanks for any help on this.
|
|
|
|
|
All DoEvents does is process any pending windows messages sitting in the apps window message queue. It's not a second message pump, but it does suspend everything in the UI thread and handles the remaining messages, then it lets UI thread processing resume as normal.
There is a difference though. The old VB6 DoEvents called Thread.Sleep, where as the .NET implementation does not.
I'd serisouly consider scrapping the DoEvents stuff as soon as possible and transfer the long-running work to either background threads, BackgroundWorker, or Tasks. Doing so will take a considerable rewrite of your code.
|
|
|
|
|