
tfowler
Avatar/Signature-
Posts
85 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by tfowler
-
Export a dataset to an Excel file
tfowler replied to karmah's topic in Interoperation / Office Integration
The simplest solution I use is just to save it as a delimited text file (tab, comma, whatever), and then Excel can import it. In addition, it is not limited to Excel. Todd -
Not that I've used it much, but it looks like all you need to do is specify the Data Source (path to the file) and Password (if it is password protected). You also may need to add a reference to "System.Data.SqlServerCe". You can then access your database through a SqlServerCe.SqlCeEngine object: Code: Dim connection As New SqlServerCe.SqlCeConnection("Data Source=C:\MySqlServerCompactDb.sdf;Password=password") Dim command As New SqlServerCe.SqlCeCommand("SELECT * FROM MyTable", connection) connection.Open() Dim results As SqlServerCe.SqlCeDataReader results = command.ExecuteReader(CommandBehavior.CloseConnection) or something like that. Todd
-
I noticed that you edited your question after Nate had answered, so I thought I would help get Nate's point across: What he means is that you did something like this: Public Class Form Private Sub Form_Load() Handles Form.Load Dim person1, person2, person3, person4 As String '<= NOTE: personX are local to Form_Load person1 = "Guy1" person2 = "Guy2" person3 = "Guy3" person4 = "Guy4" End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged TextBox2.Text = person1 End Sub End Class What you need to do is: [left][color=#b1b100]Public Class Form Dim person1, person2, person3, person4 As String '<= NOTE: personX are now local to all of the Form class Private Sub Form_Load() Handles Form.Load person1 = "Guy1" person2 = "Guy2" person3 = "Guy3" person4 = "Guy4" End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged TextBox2.Text = person1 End Sub End Class [/color] [/left]
-
I've used iTextSharp to print directly to a PDF (not convert from DOC). The documentation is not that great, but I was able to figure things out on my own relatively easily. It definitely took some trial and error.
-
Are you using Visual Studio.NET? If so, select Project -> Add Windows Form and select the About Box template. If not, you'll have to design your own new form. Then you'll have to instantiate the Form and call WhateverYouNameTheForm.ShowDialog() in the Click event of your "About 5th G" menu item. Todd
-
I've recently started to use LinqToSql. So far, it has been working very well to automatically create business objects from the database tables.
-
Inserting Data: Technique Question
tfowler replied to joe_pool_is's topic in Database / XML / Reporting
I can't tell you why they do that. My first couple of applications used the SqlDataAdapter method too. I don't remember when I figured out that it was overkill for what I was trying to accomplish. Yes. You would create your SELECT statement to only return Column2 and then do something like: VAL2 = cmd.[size=2]ExecuteScalar() [/size] Of course ExecuteScalar returns an object, and so it would need to convert it to your needed data type. Look into the ExecuteReader method. If you want an example, I can give you one later, but I gotta go right now. Todd -
Inserting Data: Technique Question
tfowler replied to joe_pool_is's topic in Database / XML / Reporting
Why use a SqlDataAdapter at all? I usually do it something like this: string insert = "INSERT INTO Table2 ([Column1], [Column2], [Column3]) " + "VALUES (@VAL1, @VAL2, @VAL3)"; SqlCommand cmd = new SqlCommand(insert, m_db); m_db.Open(); try { cmd.Parameters.Add("@VAL1", SqlDbType.VarChar, 20).Value = strValue1; cmd.Parameters.Add("@VAL2", SqlDbType.VarChar, 20).Value = strValue2; cmd.Parameters.Add("@VAL3", SqlDbType.VarChar, 20).Value = strValue3; int nCount = cmd.ExecuteNonQuery(); if (nCount != 1) { Console.WriteLine(string.Format("{0} records were affected.", nCount); } } catch (SqlException e) { Console.WriteLine(e.Message); } finally { cmd.Dispose(); m_db.Close(); m_db.Dispose(); } assuming that m_db is your SqlConnection object. Todd -
"You won't find a more feature-rich, stable and reliable service for the price."
-
A little Googling got me this link: http://www.jcxsoftware.com/ Todd
-
Performing a count on an additional table.
tfowler replied to mike55's topic in Database / XML / Reporting
I've done something similar to this in the past. I think it would be something like: SELECT dbo.Organization.Org_ID, dbo.Organization.Org_Name, dbo.SMS_Credit.Credit, CONVERT(VARCHAR(10), dbo.Org_MemberShip.Start_Date, 103) AS Start_Date, CONVERT(VARCHAR(10), dbo.Org_MemberShip.Finish_Date, 103) AS Finish_Date, dbo.Org_MemberShip.Status, dbo.Org_MemberShip.Subscription_Type, dbo.Organization.Org_Country, dbo.Organization.DialingCode, dbo.Organization.Org_Email, dbo.Organization.Org_Phone, dbo.Organization.Addr1, dbo.Organization.Town, dbo.Organization.County, dbo.Organization.Member_Numb, dbo.Login.Email_Add, dbo.Login.UserName, dbo.Login.PlainPass, dbo.Org_Profile.AllowContact, dbo.Login.Login, dbo.Login.Forename, dbo.Login.Surname, message_count= (SELECT COUNT(dbo.SentMessages.org_id) FROM dbo.SentMessages WHERE dbo.SentMessages.org_id=dbo.Organization.Org_ID) FROM dbo.Organization INNER JOIN dbo.Org_MemberShip ON dbo.Organization.Org_ID = dbo.Org_MemberShip.Org_ID INNER JOIN dbo.SMS_Credit ON dbo.Organization.Org_ID = dbo.SMS_Credit.Org_ID INNER JOIN dbo.Login ON dbo.Organization.Org_ID = dbo.Login.Org_ID INNER JOIN dbo.Org_Profile ON dbo.Organization.Org_ID = dbo.Org_Profile.Org_ID where (Org_Membership.Subscription_Type = 'trial' or Org_Membership.Subscription_Type = 'full') Todd -
Try the opensource tool iTextSharp (http://itextsharp.sourceforge.net/). The documentation isn't very clear (since it was ported from a Java tool), but once you get it working, it works very well. I've used it for a couple of projects. Todd
-
The "Dim strPath..." statement gets the path to the directory from which the application is executing (which is obviously where he expects to find his XML data). The "dsEquip.ReadXmlSchema..." statement gets the schema information for the XML file. A schema file describes the structure of an XML file. For instance, when you save a DataSet to an XML file using DataSet.WriteXml, with the XmlWriteMode.WriteSchema option, it will create a schema file for you that defines such things as: which nodes are the tables vs which nodes are the columns, etc. If you do not have a schema file, the DataSet.ReadXml method has to try to figure out the schema from the data. If unsuccessful, you either get an exception, or no data in the DataSet. Todd
-
Ok, I have searched the web forever for this and found suggestions, but none of them seem to work for my stituation. So, here I am. I am using AJAX.NET 1.0. I have a page with two UpdatePanels. The first contains a DropDownList and three Panels which contain various controls. When the user selects an item from the DropDownList, the appropriate Panel is displayed, while the others are hidden. This works great. The second UpdatePanel control contains a GridView. Right-clicking and dragging on the GridView paints the cells different colors (using a JavaScript routine) depending on the selection in the DropDownList. This works great when the page first loads, but stops working after a different item is selected from the DropDownList. I have read a variety of threads about using ScriptManager.RegisterClientScriptBlock to register my JavaScript code. I have tried to do this in Page_PreRender, Page_Load, UpdatePanel1_PreRender, UpdatePanel1_Load, UpdatePanel2_PreRender, UpdatePanel2_Load, and all of the combinations at once...but I can't get it to work! I'm at a complete loss. My JavaScript looks something like: [size=2]<script language="javascript" type="text/javascript">[/size] [size=2]/* script for changing the background color of the table cells based on the "Selection Mode" */[/size] [size=2]document.getElementById('<%GridView1.ClientID %>').onmousemove = MouseMove;[/size] [size=2]document.getElementById('<%GridView1.ClientID %>').onmousedown = MouseMove;[/size] [size=2]document.getElementById('<%GridView1.ClientID %>').oncontextmenu = DontShowContext;[/size] [size=2]document.getElementById('<%GridView1.ClientID %>').onmouseup = MouseUp;[/size] [size=2]// handle the MouseMove event for the GridView control[/size] [size=2]function MouseMove(event)[/size] [size=2]{[/size] [indent][size=2]:[/size][/indent] [indent][size=2]:[/size][/indent] [indent][size=2]WITH THE CODE TO CHANGE COLORS HERE[/size][/indent] [size=2][[/size]/code] So, registering all of the JavaScript using [b]ScriptManager.RegisterClientScriptBlock[/b] doesn't work because I get errors about the GridView object not existing (since it hasn't been rendered yet). So, I split the non-funtion code out and try to register it using [b]ScriptManager.RegisterStartupScript[/b]. I no longer get the script errors, but I am back to the original problem! Thanks for any help you can provide, Todd http://forums.asp.net/emoticons/emotion-7.gif
-
I'm not sure where you got the instructions to enable AJAX in your application, but you seem to be missing a lot in your web.config file. Check out this video tutorial: http://www.asp.net/learn/videos/view.aspx?tabid=63&id=81 He goes through the entire process of adding AJAX capability to an existing site. Once the AJAX web.config information is added, you need to add a ScriptManager control to the page. Then add an UpdatePanel control (and ContentTemplate) that surrounds the Panel control, along with the Button control you will use to control the Panel visibility. Let me know if you need more details, Todd
-
I think you'll end up using AJAX. It is very simple to use in this type of situation. I place the controls I want to show/hide in a Panel control and change the visiblity of it. Todd
-
I agree with almost everything marble_eater said. Although, I am a little suprised that IBM would go along with Microsoft on this without securing some support on Linux. IBM has supported open source software for a while now. Are they changing their stance? I am very, VERY wary about upgrading to Vista (stricter DRM, limited number of installations, etc). As far as I can tell Vista does nothing for me (except being prettier than XP). Microsoft has just released Vista to try to further lock up the market. Yeah, they talk about increased security, less viruses, blah, blah, blah. But if those "improvements" make it harder for me to work, then, no thanks. A couple of months ago I was having some problems on my laptop with XP and decided to give Ubuntu Linux a try. So far I am very impressed. I am now thinking that I will stick with Ubuntu (or some other form of Linux) for all of my home machines. I've still got to test out some Linux PVRs to see if they could replace my Microsoft Windows XP with BeyondTV PVR. If so, goodbye Microsoft! FOSS all the way! Unfortunately, I have less of a choice at work. I will have to continue using Microsoft products. Yeah, I could try and talk my work into switching, but that would entail a ton of work and money for very little return (in their view). I could also look for another job with a company that uses Linux, but those are very few and far between (especially here in Columbus, Ohio). Todd
-
It all has to do with "value" vs. "reference". "" means that the String object exists, but contains an empty String. 'Nothing' means that the object has not yet been instantiated (with the New keyword). So, checking the value of a TextBox.Text, you would check for an empty String (""), since the Text parameter of a TextBox is instantiated when the TextBox is instantiated. You can always use both: If someString IsNot Nothing AndAlso someString <> "" Then 'do something End If If the string was defined but not instantiated, e.g.: Dim someString As String If someString Is Nothing Then 'this would be True End If If someString = "" Then 'this would cause a run-time exception, since someString 'has not yet been instantiated End If 'you could keep the runtime exception from happening by checking it like this: If someString Is Nothing OrElse someString <> "" Then 'this would be True if either the someString object was not yet 'instatiated, or, if someString contains an empty string End If 'it is generally a good idea to define a String this way to keep 'the runtime error from happening: Dim someOtherString As String = "" If someOtherString Is Nothing Then 'this would be False End If If someOtherString = "" Then 'this would be True End If '<>' means "the contents of the object are not equal to". 'IsNot' means "the variable names do not point to the same object in memory". So, If someString <> someOtherString Then 'the contents of someString do not equal the contents of someOtherString End If If someString IsNot someOtherString Then 'the variable name someString does not point to the same 'object in memory as the variable name someOtherString End If This may not explain everything, but I hope it points you in the right direction. Todd
-
4GuysFromRolla has a good tutorial on this subject: http://aspnet.4guysfromrolla.com/articles/120705-1.aspx Todd
-
I spent almost an entire day figuring out how to use custom configuration settings in an app.config.:mad: I never really found any good examples of how it should be done:( , so I decided to share what I learned here.:D You can always store key/value pairs in the app.config file and read them using the AppSettings function. However, what if you have a more complicated situation where you need to group settings. That is where a custom configuration comes in. Note: you can always create your own XML settings file, but I like having a single place for all of the application settings. So, say I have 3 different kinds of "things" that have 3 different properties that I want to retrieve. I set up my app.config file as follows: [size=2][color=#0000ff]<?[/color][/size][size=2][color=#a31515]xml[/color][/size][size=2][color=#ff0000]version[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]1.0[/color][/size][size=2]"[/size][size=2][color=#ff0000]encoding[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]utf-8[/color][/size][size=2]"[/size][size=2][color=#0000ff] ?>[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]configuration[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff] <!--[/color][/size] [size=2][color=#008000] define the custom section[/color][/size] [size=2][color=#008000] note that the 'type' is full name for the class that will be used to access[/color][/size] [size=2][color=#008000] the custom section and the namespace. We will define this class later[/color][/size] [size=2][color=#0000ff] -->[/color][/size] [/color][/size][size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]configSections[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]section [/color][/size][size=2][color=#ff0000]name[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]SomeCustomSettings[/color][/size][size=2]"[/size] [size=2][color=#ff0000] type[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]ConfigurationExample.SomeCustomSettingsSection, [/color][/size] [size=2][color=#0000ff] ConfigurationExample[/color][/size][size=2]"[/size][size=2][color=#0000ff]/>[/color][/size] [size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]configSections[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff] <!--[/color][/size][size=2][color=#008000] here is the start of our custom configuration settings section [/color][/size][size=2][color=#0000ff]-->[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]SomeCustomSettings[/color][/size][size=2][color=#0000ff]> <!--[/color][/size][size=2][color=#008000] this is the ConfigurationSection [/color][/size][size=2][color=#0000ff]-->[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]things[/color][/size][size=2][color=#0000ff]> <!--[/color][/size][size=2][color=#008000] this is the ConfigurationElementCollection [/color][/size][size=2][color=#0000ff]-->[/color][/size] [size=2][color=#0000ff] <!--[/color][/size][size=2][color=#008000] these are the ConfigurationElements [/color][/size][size=2][color=#0000ff]-->[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]add [/color][/size][size=2][color=#ff0000]name[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]Thing1[/color][/size][size=2]"[/size] [size=2][color=#ff0000] property1[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]Thing1's property1[/color][/size][size=2]"[/size] [size=2][color=#ff0000] property2[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]100[/color][/size][size=2]"[/size] [size=2][color=#ff0000] property3[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]Thing1's property3[/color][/size][size=2]"[/size] [size=2][color=#0000ff] />[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]add [/color][/size][size=2][color=#ff0000]name[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]Thing2[/color][/size][size=2]"[/size] [size=2][color=#ff0000] property1[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]Thing2's property1[/color][/size][size=2]"[/size] [size=2][color=#ff0000] property3[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]Thing2's property3[/color][/size][size=2]"[/size] [size=2][color=#0000ff] />[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]add [/color][/size][size=2][color=#ff0000]name[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]AnotherThing[/color][/size][size=2]"[/size] [size=2][color=#ff0000] property1[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]Thing3's property1[/color][/size][size=2]"[/size] [size=2][color=#ff0000] property2[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]200[/color][/size][size=2]"[/size] [size=2][color=#0000ff] />[/color][/size] [size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]things[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]SomeCustomSettings[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]configuration[/color][/size][size=2][color=#0000ff]>[/color][/size] I now need to create classes to access this information. See the attached files for the complete example (since we are limited a paltry 10000 characters :mad: ). Hope this example helps someone. I tried to make it much clearer than any of the MSDN documentation or other examples that I found. Let me know if there is anything that I should modify to improve clarity, or if anyone has any questions. Todd ConfigurationExample.zip
-
You'll likely have to use JavaScript to do this. Something along the lines of what is described in this link: http://jennifermadden.com/javascript/stringEnterKeyDetector.html Todd
-
I agree with PD. You wouldn't want to have to maintain those 2000 accounts on two different servers...that would be a nightmare!
-
The DataSet object still exists: [font=Courier New][size=2]System.Data.DataSet [/size][/font] Although, I would think that you wouldn't want all of that overhead just to determine if there is data in a database table. Why wouldn't you use something like: Dim con As New System.Data.SqlClient.SqlConnection(<your connection string>) Dim com As New System.Data.SqlClient.SqlCommand("SELECT COUNT(*) FROM <your table name>", con) con.Open() Dim rowCount As Integer = CType(com.ExecuteScalar, Integer) con.Close() If you are going to use the data in the DataSet after you check to see if it has rows, then, by all means, fill the DataSet. But, don't just fill a DataSet to check the number of rows and then discard it. Todd