Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. http://www.xtremedotnettalk.com/showthread.php?t=74918&highlight=garbage+collection+dispose http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69454 may be worth a read. In brief you really only need to look at using dispose if the objects you are creating hold references to limited / critical / expensive resources (file handles, database connections etc.) Variables that contain references to objects will ultimately be garbages collected when .Net feels there is a need. Value types (structs) will be reclaimed as soon as the procedure exits.
  2. The techniques in this thread should give you an idea how to access an embedded resource, you would just need to save the stream to a physical file rather than using it directly.
  3. You need to provide either a user id / password or the integrated security = true, not both. Also is the server set to allow SQL logins (see my above post)?
  4. for Windows Forms and web forms
  5. Any chance you could post the code you have now? Or the table structures? Also http://support.microsoft.com/default.aspx?scid=kb;en-us;308278 may be worth a look - although it talks about access the concepts are the same. ps. in the subject you say VBII - what version of VB are you using?
  6. To create a 2D array use static int[,] array = { {1,2}, {3,4} }; the int[][] syntax declares a jagged array General info on the types of arrays found in c# can be found here
  7. To use the sa account SQL server needs to be setup to use what is know as 'Mixed Mode' security. If you start enterprise manager and right click on your server and select properties, then go to the security tab. You will need to select the option labeled 'SQL Server and Windows'. Then press OK and restart the SQL Server service. Having a blank sa password is highly insecure and a major security risk Rather than using SQL security you may be better of using integrated security. To do this you will need to create a login in SQL for the ASPNET account (enterprise manager, security, logins) and modify your connection string to be "Integrated Security=true;initial catalog=Northwind;data source=;Connect Timeout=60;max pool size=400" that should fix the problem, if not let me know what errors are generated.
  8. Try something like the following Dim objSQLConn As SqlConnection objSQLConn = New SqlConnection 'set the connection string from the web.config file objSQLConn.ConnectionString = ConfigurationSettings.AppSettings.Get("ConnectionString") 'Open a connection to the SQL database objSQLConn.Open() Dim cmd As New SqlCommand cmd.Connection = objSQLConn cmd.CommandText = "sp_customers" cmd.Parameters.Add("@customerID", textbox1.text) cmd.Parameters.Add("@companyname", textbox2.text) cmd.Parameters.Add("@contactname", textbox3.text) cmd.ExecuteNonQuery(objSQLConn, "sp_customers", SqlParams)
  9. string s = (string) Application["UploadDir"];
  10. The web.config is really just a convenience, it prevents you from having to hard code things like connection strings into the database. You can use any value for the key - just select something that makes sense. Once you have defined a key in the web.config you can then use it in your code via the AppSettingsReader class. e.g. given the following web.config entry the code to access and use it would be something like Dim configurationAppSettings As System.Configuration.AppSettingsReader = New System.Configuration.AppSettingsReader dim conn as = New System.Data.SqlClient.SqlConnection conn.ConnectionString = CType(configurationAppSettings.GetValue("NorthwindConnection", GetType(System.String)), String) conn.Open 'now use connection as per normal this means an administrator could change the connection string by simply editing the web.config without having to recompile/ restart the web application.
  11. Rather than displaying the MainForm as a dialog with MainForm.ShowDialog you could just use Application.Run(MainForm) this will allow your main form to process the windows message pump and prevent the app exiting till MainForm closes.
  12. You may also want to investigate the command line tool ngen.exe, this will precompile your .Net assemblies into native machine code and avoid the overheads of the JIT compile. However it may not always be the best option.
  13. You shouldn't need to call the Form2.Hide() from your button1_click - if the form is a displaye dwith .ShowDialog() then clicking the button will hide the form automatically - but you should still be able to access it's controls / properties from code. Also you may need to modify your switch statement a little.... frmProjectLayout oProjectLayoutForm = new frmProjectLayout(this.oMainForm); DialogResult res = oProjectLayoutForm.ShowDialog(this.oMainForm); switch (res) { // ok was pressed case DialogResult.OK: // populate user selected vars this.oName = oProjectLayoutForm.o_FrameName; this.oFrameSizeF = new SizeF(oProjectLayoutForm.o_FrameSize.Width, oProjectLayoutForm.o_FrameSize.Height); case DialogResult.Cancel: break; }
  14. how about double d = double.Parse(txtNum1.Text) + double.Parse(txtNum2.Text); txtTSCTax.Text = d.ToString("C");
  15. A redesign when moving from VB6 to .Net may extend the schedule but it could allow you to take full advantage of .Net features that didn't exist in VB6 (inheritance, delegates, new collection classes etc), as well as being able to remove many API / OCX / COM DLLs that were required to implement things that are now native to .Net.
  16. Web applications behave differently from Windows applications. A windows application will maintain state as long as the application is running and as such will persist the DataSet between button clicks. Web applications however lose their state between postbacks (button clicks etc) and will require either the DataSet to be recreated on each page refresh or for it to be deliberately stored on the server (probably as a Session, Application or Cache variable, depending on your requirements). To allow a simple Next button to work you would need to store the current position in the DataSet so it could be accessed across postbacks (probably using Session, ViewState or QueryString). This would need to be read each time the page is refreshed and the appropriate data retrieved and used to populate the page.
  17. In that case look into AddHandler and RemoveHandler basic syntax is Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click AddHandler ListBox1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click RemoveHandler ListBox1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged End Sub Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Your event handler here End Sub the addhandler will dynamically wire up the event at runtime while removehandler will un-wire the event handler.
  18. Is the dll listed under the references correctly? Is the namespace correct?
  19. This method will also prevent ASP.Net from being able to pool SQL connections and as such could cause performance issues
  20. Dim nn as new NamespaceInDll.ClassINDll() should work. Is the class in the cs file declared as public class ClassInDll though? If not it will need to be public
  21. You can overload the finalize method it's just that C# forces you to use the C++ destructor syntax. class class1{ class1() { //constructor code goes here } ~class1() { //this is the finalize method } } Dispose is not called by the garbage collector though. If you have already implemented a dispose method you should really do most of your clean up there. One possibility is get the Dispose method to call your finalize method internally and then have it execute a GC.SupressFinalize(this) to prevent the GC calling the finalize a second time. You may find this link useful. Just out of interest what does the class do? Unless you are dealing with unmanaged / expensive resources you may not need to worry about freeing up the memory yourself.
  22. Is this a windows app? If so then you will not need either the DataBind or the Page.IsPostBack bits.
  23. You could use code similar to the suggestion in this thread to redirect the output from ipconfig. you would then just need to search through the returned data for lines containing the term "physical address". If you can't get it working post again and I'll see what I can do. Out of interest have you considered using WMI to retrieve the MAC address rather than parsing the output of ipconfig /all, think I saw a recent post from dynamic_sysop about that....
  24. http://www.xtremedotnettalk.com/showthread.php?goto=newpost&t=83092 may be of some use
  25. Either that or store the datatable in either the session oject or the Cache object.
×
×
  • Create New...