Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. Quick example.... object o; o = Activator.CreateInstance(Type.GetType("System.DateTime")); however note that because I've declared the variable as object I have no access to the members of DateTime. Could you give a bit more detail on what you are trying to do as there may be a better / easier way.
  2. Like I said above the word GO is supported by Query Analyzer but isn't a valid SQL keyword - it will not work if you try to use it in code being executed from a SqlCommand
  3. You will also need to provide the DataAdapter with a valid InsertCommand.
  4. What's the code behind the button in question?
  5. In that case as far as I'm aware you will have to do the check before calling the function.
  6. Creating a Finalize method can result in your class taking longer to be garbage collected by the runtime. All class that have a finalize method get place in a queue behind the scenes and when the object goes out of scope it waits till garbage collection occurs, then calls the .Finalize method and only then is this particular object eligible for Garbage collection i.e. on the next pass of the collector. If your object maintains non-managed / expensive / limited resources (file handles, data base connections etc.) then a finalizer is probably required, any other scenario and they probably are not. If you are going to implement a Finalizer then you should also implement IDisposable as wyrd suggested - this way you allow the calling code to call your clean-up at a known point in time, but if you forget then the GC will get it eventually (note the word eventually - there is no way to determine exactly when).
  7. You could create a class that inherits from Control, implement the functions there and inherit ClassA and ClassB from this new class, or if there is no common code and you merely need the function to be present then you could define and implement an Interface.
  8. Can't tell what the SQL code looks like from your posting but the error message indicates a syntax error. Do you have the keyword 'GO' in the SQL you are trying to execute by any chance? If so that is the problem, GO is not a SQL keyword - it is really an instruction to the SQL tools (Query analyzer, isql and osql). If you remove the word GO does that fix the problem? If not could you post the SQL that is being executed and any new error messages that may be returned.
  9. Certainly - it was why I suggested the change:D
  10. Rather than storing them in a module (bad OO practice anyway) you could store them in a class and then store the class in a session variable. May not be the cleanest code but will probably be the quickest fix if time is short....
  11. 1 byte per character for char/varchar, 2bytes per character for nchar/nvarchar. a char/varchar field can hold approx 8,000 characters while a nchar/nvarchar can hold approx. 4,000 characters.
  12. How large an InvoiceNumber do you use? a char/varchar can hold approx. 8K of text while the unicode variants (nchar/nvarchar) can hold approx 4K of text - are these not suitable. Text as a datatype is really a large binary field and can store up to 2G of data per field - it's this large storage capacity that prevents it's use in certain situations i.e. grouping, indexing etc. If I was you I'd rethink the choice of data type and also investigate to see if it has been used elsewhere in the data base. There are many reasons to avoid Text as a data type for smaller string based dataitems (indexing, potential performance issues, recoverability, issues with replication etc.)
  13. There is a tutorial in our 'Tutor's Corner' you may find helpful. Click here
  14. float fCost = float.Parse(TextBox9.Text);
  15. When you say it doesn't work - could you give a few more details? What error (if any do you get)? Also have you defined an UpdateCommand in the DataAdapter? If not you will need to.
  16. You would need to refer to the session variable in the relevant events (e.g. Page_Load) or alternatively you may want to investigate ViewState for controls.
  17. The problem has been noted and is being investigated. It doesn't affect IE, did affect Mozilla 1.6 but not 1.7a (my browser of choice) so it may be a DHTML problem with then Gecko rendering engine....
  18. Private Sub Cash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cash.Click dim TimeClicked as integer TimeClicked=Session("ClickCount") Dim txtbox As New TextBox() txtbox.Width = Unit.Pixel(100) txtbox.Height = Unit.Pixel(20) PlaceHolder1.Controls.Add(txtbox) TimeClicked = TimeClicked + 1 Session("ClickCount")=TimeClicked messagebox.show(TimeClicked) 'This won't work in asp.net anyway though End Sub
  19. if txtCCC.Text.Trim = String.Empty then end if
  20. IIRC you can't use a parameter to substitue for a tablename like that, you would have to dynamically construct the SQL. You could do something like Me.SqlSelectCommand1.CommandText = "exec 'SELECT * from ' + @name" Me.SqlSelectCommand1.Connection = Me.SqlConnection2 Me.SqlSelectCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.)) not sure if the syntax is exact though - nowhere near a SQL box at the moment. If it's wrong reply and I'll have another look later when I am near SQL.
  21. When you say it gaives an error could you be more specific? What error does it give? Does it give a line number? Have you properly initalised your command and connection objects (and remembered to open the connection - I always forget that one).
  22. IIRC, If you have the function declared correctly in C# then you should be able to call it like Midi.SendMsg(0x99, 38, 127)
  23. Not sure what you mean by this? Is your hex number stored as a string with the '&H' bit included or just as a number type?
  24. Personally I've always hated prefixing variable names with the variable type (strName, iID, lValue etc). This type of naming can cause more trouble than anything - a fairly frequent occurence is the variable type changes but nobody has the urge to go and rename every instance of the variable in case they screw something else up, the number of times I've seen variables (especially in VB6) like iID which is a long (not an integer), the name is misleading. If the variable is declared so far from the point of usage that you don't know what it does then perhaps a better name / code structure may be in order, plus intellisense and a decent IDE make a lot of the reasons redundant anyway. As to using camel case etc at first I found it a bit of a pain switching to it but now I tend to do it second nature and it makes sense, I can tell a Method from a Parameter from a local variable from a class variable at a glance - plus if you are creating a re-usable library then it makes sense to follow Microsoft's guidelines. However I do find it useful to use a prefix for controls, I guess some old habits die hard..... If you are serious about this kind of thing then you may find FxCop a useful tool. also for another (humerous) opinion on hungarian style names have a look here point 29 especially. :D
×
×
  • Create New...