Jump to content
Xtreme .Net Talk

davearia

Avatar/Signature
  • Posts

    185
  • Joined

  • Last visited

davearia's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. 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.
  2. What permissions have you set up on that folder?
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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?
  8. 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?
  9. I tend to set the panel to be not visible when I am updating it contents if the flickering occurs.
  10. I normally use: If DataGridViewX.CurrentRow.Cells.Item(0).Value IsNot System.DBNull.Value Then '??? End If
  11. 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.
  12. 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.
  13. 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!!!!!
  14. I took the 2nd option on your recommendation and it works a treat. Thanks for your help mate.:D :D :D
  15. 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.
×
×
  • Create New...