|
If this code is running server-side, then you only have to supply the fully qualified path. BUT!! That will only work if the ASP process has Read permissions to the path being references.
Filepath = "C:\yadda\yadda"
If this code is running client-side, there's nothing you can do except change your design. The web server will NOT give clients access to anything outside of the side directory that the page was served from.
|
|
|
|
|
Thanks for responding...
I am using this in server side code (classic ASP between the sript (<% %>) tags.)
I used the fully qualified path but got the following error:
Error Type:
Server.MapPath(), ASP 0172 (0x80004005)
The Path parameter for the MapPath method must be a virtual path. A physical path was used.
/HFHS/Code/Debugging.asp, line 16
Browser Type:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
-DWreck
|
|
|
|
|
So what's not to understand?? If this is server side code, all you have to do is provide the fully qualified path. You don't have to use Server.MapPath! I already gave you an example of this in my previous post. This is, like I stated in my previous post, subject to the limitations of NTFS Security and the account under which your ASP site is running.
|
|
|
|
|
I populate a combobox as follows:
<code>ComboBox2.Items.Clear()
ComboBox2.Items.AddRange(ScanHistoryList)
ComboBox2.SelectedIndex = 0</code>
ScanHistoryList is a string array.
I want to be able to allow the user to add to/edit the combobox .
How do I do this?
Any help much appreciated - I can't find a property to set
You always pass failure on the way to success.
|
|
|
|
|
I think you need to achive this prgamatilally by traping the events and if the text is changed while drop down event replace the older text with new one and if older text is a blank then add the new Item inthe list.Just try it
|
|
|
|
|
Thanks I'll give that a go
You always pass failure on the way to success.
|
|
|
|
|
Hmmm... I guess you could put a button next to the ComboBox, called Edit, that gets the current SelectedItem in the ComboBox, and put the text of the item into a small form with a TextBox. That form would have a OK and Cancel button. If OK, then the SelectedItem would be replaced with the new text.
|
|
|
|
|
Thanks Dave and Ciacia,
I've solved it.
First thing I did was turn it into a DropDown rather than DropDownList. This allows the users to edit the data
Then I created the following event handlers:
<code> Private Sub ComboBox2_SelectedTextChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.TextChanged
textChanged = True
End Sub
Private Sub ComboBox2_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.Leave
If textChanged Then
ComboBox2.Items.Insert(ComboBox2.Items.Count, ComboBox2.Text)
ComboBox2.SelectedIndex = ComboBox2.Items.Count - 1
End If
End Sub
</code>
Note: textChanged is declared as a boolean variable.
What happens then is that when the user leaves the combobox if they have changed any text: this is added to the end of the combobox array collection and this is then made the current selection.
Thanks for your help guys. It's a shame that something which seems so simple can be so tricky!
You always pass failure on the way to success.
|
|
|
|
|
|
I don't see anything wrong with this approach. Quick and easy
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi All,
Being a dot net beginner, i would like to know about biztalk.
What is biztalk? whats it role and how it can be used?
Please explain with an example.
Thanks.
|
|
|
|
|
|
Sharepoint doesn't have anything to do with the .NET Framework. Read up on it here[^].
d_smita wrote: where and How can i implement it ?
Why would you want to do that when you don't know anything about it?
|
|
|
|
|
How can i make a stopwatch ? (Using VB.NET)
|
|
|
|
|
hope this will help you.
SSK.
|
|
|
|
|
you can also use:
Dim sw As New Stopwatch
sw.start
'do what you want to do
sw.stop
secondspassed = sw.ElapsedMilliseconds/1000
This seems much less complicated than the other way to do
|
|
|
|
|
hi
i want to create a PDF files using a HTML/DOC Source file using vb.net.
can somebody help me?
Thanks
|
|
|
|
|
hope this will help you.
SSK.
|
|
|
|
|
Hey guys, I'm having a little trouble with what I'm trying to do. I think there is just one or two lines of code that need to be entered (to what I already have), but I'm not exatly sure what it is.
What I'm trying to do extract one record from a SQL database, because right now I have the SQL statement in a combobox with visable disabled, and I know that's not correct.
Here is what I was thinking, and if this is totally wrong just let me know.
Sub Temp(ByVal myConnString As String)
Dim mySelectQuery As String = "SELECT MAX(TicketID) AS Expr1 FROM tblTicket"
Dim myConnection As New Data.SqlClient.SqlConnection(myConnString)
Dim myCommand As New Data.SqlClient.SqlCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As Data.SqlClient.SqlDataReader
myReader = myCommand.ExecuteReader()
myReader.Close()
myConnection.Close()
End Sub
The exact bit of data I want to extract is what would be in "Expr1".
I've tried several different things, as in...
Dim Number as Double
...
Number = myReader...
Hopefully there is just a few lines of code that can be entered to extract that data, if anyone can help me I'd really appreciate it.
Thanks,
aqzman
|
|
|
|
|
If you are only ever going to retrieve the first column of the first row (or that the data only has one row, and the row only has one column) then you can use ExecuteScalar() - That will save you faffing around with DataReaders.
Here is an updated snippet:
myConnection.Open()<br />
Dim someValue As Object = myCommand.ExecuteScalar();<br />
myConnection.Close()
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
That worked like a charm!
Thanks a lot for the help!
|
|
|
|
|
I answered your question in the sql forum, please don't cross post and please put more meaningful subject lines in your posts.
Ben
|
|
|
|
|
|
|
Hi, I got a problem that I could not solve when try to read my data from ms access database into the list box. I have the following code:
Under the form public class:
Private WithEvents cnnDonorDb As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\DICDonorDb\DICDornorDb.mdb'; Persist Security Info=False")
I add the following code to form load event to get data from the database to the list box:
Dim cmdOrgType As New OleDbCommand
With cmdOrgType
.Connection = cnnDonorDb
.CommandType = CommandType.Text
.CommandText = "SELECT * FROM tblOrgType.OrgType ORDER BY tblOrgType.OrgType;"
End With
' Open the connection.
cmdOrgType.Connection.Open()
' Execute the command to the return the list of organization type.
cmdOrgType.ExecuteReader() ' HERE IS THE PLACE THAT I GET AN ERROR
Dim drdResult As OleDbDataReader
' Get the list of organization type and put it in the list box.
While drdResult.Read
For colOrgType As Integer = 0 To drdResult.FieldCount - 1
lsbOrgInfo.Items.Add(drdResult(colOrgType).ToString)
Next
End While
' Close the result.
drdResult.Close()
' Close the connection
cmdOrgType.Connection.Close()
I got an error as the following message:
Could not find file 'C:\Documents and Settings\roathkanel\My Documents\Visual Studio 2005\Projects\DIC Donor Database\DIC Donor Database\bin\Debug\tblOrgType.mdb'.
I really don't understand why the database path in this message is difference from database path in C: drive. As you can see the path in the connection string is C:\DICDonorDb\DICDornorDb.mdb . I'm sure that the file is located in this folder because I didn't type it, i copy the string path and file name into my code editor.
Please help me to solve this problem. I'm using VB 2005.
Thank in advance!!!
|
|
|
|