
davearia
Avatar/Signature-
Posts
185 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by davearia
-
Hi, You cannot modify the column type once you have data in there. Here is what I would do, it's in vb as I am at work. Dim dtResults As New DataTable For Each dc As DataColumn In dtOriginalTable.Columns dtResults.Columns.Add(dc.ColumnName) Next For Each dc As DataColumn In dtResults.Columns If dc.ColumnName = "columnToChange" Then dc.DataType = System.Type.GetType("System.String") End If Next For Each drow As DataRow In dtOriginalTable.Rows dtResults.Rows.Add(drow.ItemArray) If Convert.ToBoolean(dtResults.Rows(dtResults.Rows.Count - 1).Item("columnToChange")) Then dtResults.Rows(dtResults.Rows.Count - 1).Item("columnToChange") = "Permanent" Else dtResults.Rows(dtResults.Rows.Count - 1).Item("columnToChange") = "Temporary" End If Next So you bind to the new datatable and it should fine.
-
What permissions have you set up on that folder?
-
Hi, I am playing around with some Directx classes at the moment with a limited amount of success. What I have found is if I use DirectSound I can play music and choose at runtime what sound device I want to use. The only problem is that DirectSound only plays uncompressed data like WAV files it cannot use compressed files like MP3 etc. One option would be to uncompress these files before handing them to DirectSound. But I wanted to know if this is the prefered way to deal with this scenario. I have read a little on DirectShow and maybe this might be what I should look into. There is so little to read on this and the examples I find are usually in C++. Can anyone help me in finding a way to play files such as MP3's through multiple audio devices. Thanks, Dave.
-
Hi All, I am currently in the process of trying to design a strategy to write a client/server media player for my home. I have seen various commercial solutions such as Sonos and Squeezebox etc. But apart from being very expensive I also don't think they work in the way I want to. What I want is a client application that communicates through some kind of remoting process to a server application on the music server. There could be many instances of this client application on PC's and mobile devices such as PDA's and smart phones etc. On the music server there could be multiple sound cards so the capability of playing different music in different zones is an option. Why I am posting this is simply to ask what my best options and methodologies would be. I recently spoke to Sacha Barber via regarding this matteras he has wrote a similar client/server application with great results. The only thing is that his solution is purely a single zone solution. Mainly down to Windows Media Player not being capable of playing to more than one zones and multiple instances of Windows Media Player not being possible if I am wrong on this please correct me (I believe WMP classic might be possible to have more that 1 instance running). One thing that Sacha suggested was to look at using DirectX to be able to manipulate what sound card is used etc. Any suggestions and links on this would be appreciated. From what I have read WinAmp is capable of having multiple instance running. But I am not sure if you can set a different sound card for each instance. What I am asking for is if anyone has any good suggestions, starting tips or links they would recommend to assisit me in researching this. Any help is truly appreciated. Many thanks, Dave.
-
Hi All I have a site for company training. The page has a number of questions, each of which has a RadioButtonList for the user to input their answers. I build all the questions and answers along with any images in an asp:Repeater. On the OnSelectedIndexChanged event of the RadioButtonList I have the following code: ''' <summary> ''' When the user selects an answer the page scrolls to next question. ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Public Sub ScrollToNextQuestion(ByVal sender As Object, ByVal e As System.EventArgs) 'Flag to tell code when to scroll to another question. Dim selectNextItem As Boolean = False 'Get the RadioButtonList that has just been pressed. Dim obj As New Object obj = sender 'Get the client ID of this RadioButtonList. Dim clientID As String = obj.ClientID 'Stores the client ID of the label so it can be used to scroll to when the training get to the last question. Dim lblQuestionClientID As String = String.Empty For Each ri As RepeaterItem In rptQuestionnaireQuestions.Items 'Find the RadioButtobList in the repeater Dim rblAnswers As RadioButtonList = CType(ri.FindControl("rblAnswers"), RadioButtonList) If rblAnswers.ClientID = clientID Then 'This is the RadioButtonList the user has just pressed, there set flag so that code will select on the next iteration. Dim lblQuestion As Label = CType(ri.FindControl("lblQuestion"), Label) 'Make reference to this for the event of this being the last question. lblQuestionClientID = lblQuestion.ClientID selectNextItem = True Else If selectNextItem Then 'This is the control to focus to, so scroll to it. Try 'Reference the control in the repeater that we are going to scroll down to. Dim lblQuestion As Label = CType(ri.FindControl("lblQuestion"), Label) 'Render javascript to scroll to next question. ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "click", "ScrollToNextQuestion('" + lblQuestion.ClientID + "');", True) Finally 'Reset flag. selectNextItem = False End Try End If End If Next If selectNextItem Then Try 'This is the last question we don't want the page to scroll back to the start. ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "click", "ScrollToNextQuestion('" + lblQuestionClientID + "');", True) Finally 'Reset flag. selectNextItem = False End Try End If End Sub Which in turn uses the following javascript: function ScrollToNextQuestion(id) { var el = document.getElementById(id) if (el != null) { el.scrollIntoView(true); el.focus(); } } If I run the code and start at question 1, the code scrolls perfectly to the next question, until each reaches the end and then stops. The problem I have is if I say decide to answer for example question 5 without answering questions 1-4 . Instead of it scrolling to question 6 as I would expect, the code leaves the page where it was. After some experimenting I added an alert in my javascript and found that when the alert is hit the page has actully scrolled to where I want. It is only when I click the OK on the alert it then goes back to where it started i.e. question 5. The parameter being passed from my server side code to the javascript is just same. Debugging I can see no difference at all. Does anyone know of any reason why the code would scroll down and then revert back? Thanks, Dave.
-
InvalidCastException when subclassing datatable
davearia replied to davearia's topic in Database / XML / Reporting
Ds.Tables(0) is a datatable. What your saying is what I expected. Thanks for confirming this, I just wanted to know if the table in the dataset could be cast to a subclass of datatable. Just so long as I know. Cheers, Dave. -
Hi, At work we have a data access layer that has been developed by one of developers. Things is it works well enough with the exception of one thing. There is a class in this datalayer that subclasses System.Data.Datatable. So for example if I populated a System.Data.Dataset and then tried to put the first table of this dataset into this class like so: Dim dt as new myDatable dt = ds.Tables(0) I get an InvalidCastException. I have created the most basic of classes for myDatable. Public Class myDatable: Inherits System.Data.DataTable End Class Is there as interface missing or something?
-
Can I run a FileSystemWatcher on another thread
davearia replied to davearia's topic in Windows Forms
Hi Nate, Thanks for your reply. I have not been working on this code for a while. I got a bit stuck with to be honest. Apart from the issue you have posted for the app was working well enough. Until I decided to create 2 instances of the file system watch class I have written. The first watches a folder on my local machines and copies/changes/deletes/updates all files in the directory to a directory on the server. The 2nd instance watches the directory on the server and performs the same operations as the first but this time to a networked hard drive. The events went nuts and the app just locked. Would people say that using the FileSystemWatcher class as I have here is abusing this class or am I trying to do something that is within its capabilities? -
I tend to set the panel to be not visible when I am updating it contents if the flickering occurs.
-
I normally use: If DataGridViewX.CurrentRow.Cells.Item(0).Value IsNot System.DBNull.Value Then '??? End If
-
Hi All, I have been writing a little application that watches my documents and nay files/folders that are changed/created/deleted/renamed are copied to the main server. As a back up process it seems to work great. I have subclassed the FileSystemWatcher and put all of the logic in there and in my form all I need is: fileSystemWatcher fsw = new fileSystemWatcher(true, true, true, true, @"\\source\", @"\\destination", true); fsw.ShowProcess += new fileSystemWatcher.ShowProcessEventHandler(ShowProcess); fsw.SynchronizingObject = this; The code is working great with one exception. If I am doing a big process, let's say copying 1GB of music the UI is frozen as the UI thread is busy. Is it possible to put this process to a separate thread possibly using a background worker? If so can anyone give a brief example of how to do this? Thanks, Dave.
-
Sorry for not replying to this sooner. My solution in the end was to write a class that attempts to FTP a small text file by: 1. Providing no credentials 2. Providing default credentials 3. Providing specific credentials. If the user fails the 1st and 2nd test and they have not provided specific credentials, they are asked for them and saved in isolated storage for later use. In most cases it will be fine. It is just in the case of a proxy server such as our's that always asks for credentials everytime you request to go outside of the proxy. Anyway it seems to work ok.
-
New starter at C# would like to ask some questions.
davearia replied to davearia's topic in Visual C# .NET
Thanks for the replies, there is so much information there, I can say that even though I have been playing around with this for a few days or so I have learned so much. The code I posted has a lot of improving to do and I said that at the time. But I am refactoring and adding a lot of stuff to it. It it going from a little couple of days project to something far more complete. As I mentioned this project is my first really in C# so I want to get it working and put everything into it I can. On a funny note I have to tell about the FileSystemWatcher. I was watching the events as they fired whilst I pasted some folders/files into the folder the FileSystemWatcher was watching. I noticed that besides the create event firing, which I was expecting. The changing event also fired. I could see no reason why this would happen. But after giving it some thought it occured to me that if for example I recursively paste files and folders into any sub folders this would fire the changing events. What I have done is add the event handlers programatically and when I start one of the events I programatically remove the other events handlers temporarily until the process is complete and then if the finally clause of my try block add the events back. Seems to work really fast and clean. Anyway I take the point about bad exception handling and can I assure you that when this code is finished I will remove as much esxception handling as is safe to do so. Any catch blocks let will at least log the exceptions and catch more specific exceptions. Many thanks to you for your help!!!!! -
Adding event handlers to object created programatically
davearia replied to davearia's topic in Windows Forms
I took the 2nd option on your recommendation and it works a treat. Thanks for your help mate.:D :D :D -
Hi, I am creating an instance of a control within my form programatically like so: Private Sub SetUp() For Each r As DataRow In dvFilter.ToTable.Rows Dim o As New ctlMachine(sPath, r) Next End Sub Within this control there is this event: Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick RaiseEvent MouseClicked(dr) End Sub This in turn is handled by this event declaration in the same control: Public Event MouseClicked(ByVal r As DataRow) But I am struggling to reference this event at form level. How do I wire this event up to the form? Cheers, Dave.
-
After spending the last 4 years writing in VB.Net I have decided to bite the bullet and all code written at home will be written in C#. Given time I think I might try to move into a C# position if things go smoothly. Anyway in the past I did some training in Java so the syntax is reasonably familiar and VB and C# are closer than ever now. So the first question is quite simple. It is regarding the use of @ in C#. If I put the line: folderToDelete = folderToDelete.Substring(0, folderToDelete.LastIndexOf("\")); It would fail, this is to do with the backspace. It is simple to fix it: folderToDelete = folderToDelete.Substring(0, folderToDelete.LastIndexOf(@"\")); What I am not sure of is what the @ is actually doing here, can someone explain. The next question regards some other code I wrote using a fileSystemWatcher that is used to delete files/folders etc. The first thing is the codes does everything it is supposed to do, so I am happy with it in that respect. I just wondered if it could be cleaner than the way I am doing it. The problem I came across was breaking out of the recursive function. I VB I would have probably used exit sub etc. In C# I used return; instead but if you look at the code you will see I had to do quite a lot to unwind the recursion. Anyway have a laugh! :o private void fswSource_Deleted(object sender, System.IO.FileSystemEventArgs e) { if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["AllowDelete"])) { if (e.Name.Contains(@".")) { //This is a file we are deleting. if (File.Exists(_DestinationFolder + e.Name)) { try { File.Delete(_DestinationFolder + e.Name); } catch (Exception) { //Consume exception } } } else { //This is a folder we are deleting a folder. if (Directory.Exists(_DestinationFolder + e.Name)) { try { //Make reference of rootfolder, to compare to later. _RootFolder = _DestinationFolder + e.Name; //Call sub to delete folders/files etc. Delete(_DestinationFolder + e.Name); //Reset flag. _stopDeleting = false; } catch (Exception) { //Consume exception. } } } } } /// Deletes file/s / folder/s using recursion. /// </summary> private void Delete(string folderToDelete) { while (folderToDelete != _RootFolder && _stopDeleting == false) { //The code in this loop applies to all child folders of the folder we are deleting. //Attempt to delete any empty folders. foreach (string d in Directory.GetDirectories(folderToDelete)) { try { Directory.Delete(d); } catch (Exception) { //Consume exception. } } //Attempt to delete the current folder in the case of it being empty. try { Directory.Delete(folderToDelete); //Move up to parent folder when no more files are left to delete. folderToDelete = folderToDelete.Substring(0, folderToDelete.LastIndexOf(@"\")); if (_stopDeleting == false) { Delete(folderToDelete); if (_stopDeleting == true) { return; } } else { return; } } catch (Exception) { //Consume exception. } //Recursively move through child folders. foreach (string d in Directory.GetDirectories(folderToDelete)) { if (_stopDeleting == false) { Delete(d); if (_stopDeleting == true) { return; } } else { return; } } //Delete any files in folder. foreach (string f in Directory.GetFiles(folderToDelete)) { try { File.Delete(f); } catch (Exception) { //Consume exception. } } try { //Move up to parent folder when no more files are left to delete. folderToDelete = folderToDelete.Substring(0, folderToDelete.LastIndexOf(@"\")); if (_stopDeleting == false) { Delete(folderToDelete); if (_stopDeleting == true) { return; } } else { return; } } catch (Exception) { //Consume exception. } } //This code applies to the parent folder. //Attempt to go into any child folders. foreach (string d in Directory.GetDirectories(folderToDelete)) { try { Delete(d); } catch (Exception) { //Consume exception. } } //Delete any files in folder. foreach (string f in Directory.GetFiles(folderToDelete)) { try { File.Delete(f); } catch (Exception) { //Consume exception. } } //Attempt to delete the current folder in the case of it being empty. try { Directory.Delete(folderToDelete); } catch (Exception) { //Consume exception. } _stopDeleting = true; return; } I am preparing myself for some criticism but if it improves me I can take it. Cheers, Dave. :D :D :D
-
Sorry just realised I wasted my time posting this. The file name just needed the path adding to it. Apologies!
-
Hi, I am trying to programmatically start up an exe. Here is a basic example of starting up an exe in my application folder which works fine: Process.Start("my.exe", My.Application.Info.DirectoryPath) Here is an attempt to specify the location: Process.Start("my.exe", "C:\Documents and Settings\me\Desktop\new\new\Bin") Which throws an exception, as it cannot find the file. I tried this: If File.Exists(appPath & "my.exe") Then Dim processInfo As New ProcessStartInfo processInfo.FileName = "my.exe" processInfo.Arguments= "C:\Documents and Settings\me\Desktop\new\new\update\Bin" Process.Start(processInfo) End If But again I get Can anyone help? Thanks, Dave.
-
Hi, I have tried the overloaded version but didn't manage to get that to work. I don't think there is anything like citrix involved with this. But I am starting to thing that our IIT deparment have set this proxy server up in a slightly weired way. Is there anywat when configuring a proxy server thet you can stop a client's machine from accepting default credentials? The thing is that the web server machine does not use the proxy server so it is almost definitely a client issue. But as we are intending to distribute this application to clint's who also may behind a proxy server I want to make sure that it will work. I have not tried browsing to the web service from a browser on this machine I suspect it will work as it is the client machine that is preventing this from working. Saying that I will try it tomorrow when I am back at work.
-
Just thought I would mention that I had a strange problem with when having Mcafee anti virus on my machine. AS Mcafee is configured to stop mass mail sending abd ses this as some kind of threat. I configured the anti virus software to allow System.Net.Mail
-
I also tried: Dim wp As New Net.WebProxy("http://1.1.1.1") wp = System.Net.WebProxy.GetDefaultProxy wp.Credentials = System.Net.CredentialCache.DefaultCredentials WHLWebServices.Proxy = wp No luck!
-
Hi, Firstly thanks once again for your help. Two questions: 1. You suggested: I tried: Dim wp As New Net.WebProxy("http://1.1.1.1:1") wp.Credentials = System.Net.CredentialCache.DefaultCredentials WHLWebServices.Proxy = wp And... Dim wp As New Net.WebProxy("http://1.1.1.1") wp = System.Net.WebProxy.GetDefaultProxy WHLWebServices.Proxy = wp But these fail to work, how would I use these correctly? Also the declaration for the proxy, does this still need the proxy's address? 2. If I take your second option, will I need to ask the user for the proxy server's address to there also? Cheers, Dave.
-
Hi, I am writing an application that will be distributed to our clients, who may and may not have a proxy server. There are numerous calls to a web service that is on our public server. We use a proxy server at our company and when I run my application and it hits a call to the web service it fails: I can get the code to work if I hard code the values that work for our proxy server i.e. Dim WebServices As New WebServices.GeneralWebServices Dim dsResults As New DataSet Dim nc As New Net.NetworkCredential("user", "password") Dim wp As New Net.WebProxy("http://1.1.1.1:8000") wp.Credentials = nc WHLWebServices.Proxy = wp dsResults = WebServices.call() But in the case of this being on the client I won't know the credential for username, password & server name. I tried using System.Net.CredentialCache.DefaultNetworkCredentials System.Net.CredentialCache.DefaultCredentials System.Net.WebProxy.GetDefaultProxy These fail to work. The values appear to be empty for the first two but I believe that even though you cannot view these details the values will still be passed. The last one has been deprecated and also does not appear to work. Can somebody please help? Cheers, Dave.
-
I have had a partial success, but I have come across two problems. When I run the application locally in visual studio 2005 the is a mdb file in the bin folder of my solution, which works just fine. When I publish the solution using the clickOnce approach this mdb file does not get published. I managed once or twice to get it to publish to one of the other folders on the client machine but not in the folder with all the dll's etc. The second problem I got was using clickOnce from behind a proxy server. I found this link but the fix was no good: http://support.microsoft.com/kb/917952. Has anyone any ideas?
-
Thanks for that Deisel. I just wanted to know what was out there so I didn't start reinventing the wheel etc. Not read all of the link yet, but I would say that was just what I was looking for. Thanks mate! :D