|
Thanx for all the suggestions, it seems i should write the code myself. I thought there was a built in function that would do this operation on it's own
|
|
|
|
|
turtle1010 wrote: it seems i should write the code myself
That's what seperates programmers from script-kiddies.
turtle1010 wrote: I thought there was a built in function that would do this operation on it's own
Nope. Just about any library, like the .NET Framework, will offer you simple classes and methods that you use to build more complex classes, like using the GetDirectories method to build your own version of a more complex GetDirectoryTree method, like you're describing.
Noone, and God know Microsoft has a hell of a time doing this, can predict and supply every tool for you for your every need. There has to come a time where you must write the code that seperates your application from every other one that does that same thing.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Maybe something like this.
You call the method and pass in a DirectoryInfo object that is created with the root path (e.g. C:\), or any path, and it will return all the subdirectories from there. The catch it to handle the exception where you are not permitted into a subdirectory.
public static List<DirectoryInfo> GetSubdirectories(DirectoryInfo directory)
{
List<DirectoryInfo> result = new List<DirectoryInfo>();
DirectoryInfo[] childDirectories;
try
{
childDirectories = directory.GetDirectories();
}
catch (UnauthorizedAccessException uae)
{
Debug.Print(uae.Message);
return result;
}
foreach (DirectoryInfo childDirectory in childDirectories)
{
result.Add(childDirectory);
List<DirectoryInfo> grandchildDirectories = GetSubdirectories(childDirectory);
result.AddRange(grandchildDirectories);
}
return result;
}
|
|
|
|
|
you have 2 choices:
@"c:\directories.txt" or "c:\\directories.txt",
|
|
|
|
|
Sir,
I want to start learning making components(component.vb)
For that please refer me a link containing a component code.
Thanks and Regards
Pankaj
|
|
|
|
|
Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 1: <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="SingleDate.aspx.vb" Inherits="AuditLog_SingleDate" title="Untitled Page" %>
Line 2:
Line 3: <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Line 4: Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
Line 5:
Source File: /AuditLog/SingleDate.aspx Line: 3
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
Sarfarj Ahmed
|
|
|
|
|
I take it there is a question buried in this somewhere...?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hai
i'm doing a project on travel & tourism in vb.net...i've written a code for user login...but it shows some error "ret = com.ExecuteScalar()" in this line...pls can any1 help me out...
Dim com As New OleDb.OleDbCommand
Dim con As OleDb.OleDbConnection
Dim ret As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=E:\Ishu\Ishwarya\mini proj\travels.mdb")
con.Open()
com = New OleDbCommand("select count(*) from users where User Name='" + TextBox1.Text + "' and Password='" + TextBox2.Text + "'", con)
ret = com.ExecuteScalar()
If (ret > 0) Then
Dim frmobj As frmbc
frmobj.Show()
Else
MsgBox("Invalid Username")
End If
End Sub
|
|
|
|
|
What is the error?
Cleako
|
|
|
|
|
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
this was the error...was my code right??? pls reply asap
|
|
|
|
|
Here is a very interesting question for you. What if the user typed in the following into the user name text box:
' OR 1=1;--
Answer:
select count(*) from users where UserName='' OR 1=1;--' AND Password=''
And that will return a value of however many users are in your database to ret. This then allows anyone access to your application, even if they are not permitted.
You really MUST learn about SQL Injection Attacks and some Tips on How to Prevent Them[^]
By the way, your immediate error is caused because you have a syntax error in your SQL. User Name should either not have a space, or it should be enclosed in square brakets like this [User Name] .
|
|
|
|
|
Wow I didnt realize User Name was a reserved phrase, you learn something everyday!
Cleako
|
|
|
|
|
cleako wrote: I didnt realize User Name was a reserved phrase, you learn something everyday!
It isn't. But the parser will interpret it as two distinct tokens unless you put square brakets around it. It will then get confused about what the second token means.
Now, what are you going to do about your gaping security hole?
|
|
|
|
|
Colin already answered your question but Im going to have to agree with him on the straight SQL, I just didnt want to say anything. Since you are using an Access DB you are going to have to validate the input to make sure that nothing that can lead to a SQL Injection attack is entered. First rule of user interactive programming is:
"All user input is EVIL!!!!"
Cleako
|
|
|
|
|
I'm using VB.NET 2005 Express, and I am reading in the contents of a text file.
I have declared:
Dim strLine as String
I'm using the StreamReader to read the contents of the text file, and I'm putting the contents into strLine.
Unfortunately, it only seems to read in the first 16381 lines from the text file, and processes those lines without any problems - but ignores lines beyond this. All my other test files (having far fewer lines than 16381) work fine.
On this occasion, the file that I need to read is 124415 lines long and so, as a novice, I've concluded that 'String' isn't up to the job.
Can anybody point me in the right direction?
|
|
|
|
|
try to user System.Text.StringBuilder instead of string
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Thanks for your reply.
I managed to solve the problem.
I had a Try ... Catch which was hiding the real problem - which was a problem with huge numbers I hadn't anticipated having to process. Simply changing the variables from Int to Long seems to have solved the problem.
|
|
|
|
|
Hi,
I have made a second form in VB.NET , now for some calculations i have to pass some parameters to the second form. How can i do this ?
//within the main form
Private Sub cmdDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDisplay.Click
Dim results As frmDisplayExpenses
results = New frmDisplayExpenses
results.ShowDialog()
End Sub
what should i do if i want to pass the param [salary] to the second created form ?
|
|
|
|
|
|
The best way is to use properties to pass stuff back and forth, but you don't have to restrict yourself to properties you define. For instance, if you want to collect a chunk of text in the second form, you can code something like this, assuming you have a text box on the second form:
<br />
Dim MyString as string<br />
Dim dlg as new FormTwo<br />
Dim result as DialogResult<br />
<br />
dlg.TextBox1.text = "Default Value"<br />
result = dlg.ShowDialog()<br />
If result = DialogResult.OK Then<br />
MyString = dlg.TextBox1.text<br />
Else<br />
' Some kind of error handling code<br />
End If<br />
JimT
|
|
|
|
|
Hallo Friends,
Need Help
I hav deployed my vb.net(Winforms)2005 application on client m/c through setup of my application.
In application's setup i hav added merge module CrystalReports10_maps.msm.
but when i m opening my crystal report through my application on client side machine it is asking for login id & password. My database is in mysql. I m giving the userid & password tht using in my application , but it says-> Logon failed.
Application is showing other forms but asking login only for crystal report.
Please help me.
-Thanks for any help in advance.
|
|
|
|
|
Hey,
If you don't want to be prompted for database credentials when you open the crystal report you should change the database connection (in crystal, under Database > Database Expert) to use integrated security as opposed to typing in the username / password.
Later
Nathan Lindley
|
|
|
|
|
Hi,
Im using .Net 2, creating a user entry form.
How do I prevent 1 or more characters from being entered into a textbox.
For example: one textbox, I dont want a user entering slashes or single quotes.
In another textbox, I dont want the user entering single quotes.
Have I got to write a whole validation thing, or is there some sort of formatting or regex I can use?
Any response gratefully appreciated.
Mark
|
|
|
|
|
Hi Mark
You can use regular expressions as far as i know to do what you want or you could use a masked textbox in .Net 2.0.
However to do what you want you need to you use the keypress event of a textbox and ignore character you dont want to allow by setting e.handled = true.
Private Sub txtText1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtText1.KeyPress
'If the key pressed is ' or " or any type of punctuation mark then do not allow
If e.KeyChar.IsPunctuation(e.KeyChar) Then
e.Handled = True
End If
End Sub
'This will ignore a backslash
If e.KeyChar = Microsoft.VisualBasic.Chr(Keys.OemBackslash) Then
e.Handled = True
End If
Hope this Helps
Keith
|
|
|
|
|
Hi everybody
I work with many projects (Visual basic 2005) that i use in many different solutions, but i have a problem with compiling the projects. I need to set the result dir of all my proyects with base on solution's dir. Ex:
Solution dir: C:\MySolution
Proyects:
project1 code dir: C:\Proyects\Proyect1
Proyect1 result dir: c:\Mysolution\bin
project2 code dir: C:\Proyects\Proyect2
Proyect2 result dir: c:\Mysolution\bin
.....
I won't to change manually all result dir when i change the solution so i hope anyone can help me (i've tried on generation event but doesn't work)
Thank you
.J2
|
|
|
|