|
doubtful. if it is a keyword, wrap it in square brackets like [note]
Posting your select would also help us
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 )
|
|
|
|
|
Here is the code from the "SelectedIndexChanged" procedure:
Private Sub cboDenLoc_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDenLoc.SelectedIndexChanged
OleAdpNote.SelectCommand = New _
System.Data.OleDb.OleDbCommand("SELECT * from Note where matricol = '" & cboDenLoc.SelectedValue & "'")
OleAdpNote.SelectCommand.Connection = OleConexiune
DsNoteleStudenti1.Tables("Note").Clear()
OleAdpNote.Fill(DsNoteleStudenti1, "Note")
End Sub
==========================
Be positive, it helps...
==========================
|
|
|
|
|
My first question would be what is returned by cboDenLoc.SelectedValue?? Is it something that is "SQL Safe"?? Probably not. For example, what if the SelectedValue returned soemthing with a quote mark in it? It'll invalidate your SQL statement and cause an error like you're getting.
You might want to consider using a parameterized query so that anything entered is escaped properly.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I have an VB.NET application and need to edit attahment before sending it.
Here is my current code which sends email automatically using outlook.
But I need to open outlook first, in case attachment needs to be edited by user.
Does anyone know how to do it? thanks, Joseph
' Create an Outlook application.
Dim oApp As Outlook._Application
oApp = New Outlook.Application()
' Create a new MailItem.
Dim oMsg As Outlook._MailItem
oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oMsg.Subject = "Termination Notification,Final Check Needed"
oMsg.Body = "Termination Notice For Final Payroll Check" & vbCr & vbCr
' Replace with a valid e-mail address.
oMsg.To = "Joseph.Kacan@banfield.net"
' Add an attachment
' Replace with a valid attachment path.
Dim sSource As String = "\\M1Data02\josephk$\Data\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\TermReport.rtf"
' TODO: Replace with attachment name
Dim sDisplayName As String = "Termination.rtf"
Dim sBodyLen As String = oMsg.Body.Length
Dim oAttachs As Outlook.Attachments = oMsg.Attachments
Dim oAttach As Outlook.Attachment
oAttach = oAttachs.Add(sSource, , sBodyLen + 1, sDisplayName)
' Send
oMsg.Send()
' Clean up
oApp = Nothing
oMsg = Nothing
oAttach = Nothing
oAttachs = Nothing
programmer
|
|
|
|
|
Hi, I am trying to return the directories in a computer using the below syntax but i can't seem to find an appopriate string path. Getdirectories seems only to return the subdirectories of a certain string path e.g: "c:\". What i want to to retrieve ALL the directories in the computer without having point them out. If this functions isn't want i should be using then what else? Thank in advance...
Dim strArray()As String
strArray = System.IO.Directory.GetDirectories("???")
System.IO.File.WriteAllLines("c:\directories.txt", strArray)
MessageBox.Show(System.IO.File.ReadAllText("c:\directories.txt"))
|
|
|
|
|
Just a thought but I would say that you would need to look at the root and save all of the directories in some kind of dictionary object like an array, then cycle through that array and look in each of those directories deeper and deeper until there are no directories left.
Cleako
|
|
|
|
|
You need to recurse into each of the directories.
Create a method that adds all the directories in the passed in directory to the list. For each new directory the method calls itself with the newly discovered directory. Eventually your array will be full of directories.
|
|
|
|
|
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 ?
|
|
|
|