{"id":7363,"date":"2004-08-27T10:23:00","date_gmt":"2004-08-27T10:23:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/2004\/08\/27\/why-cant-i-drag-from-server-explorer-to-my-form\/"},"modified":"2024-07-05T14:58:54","modified_gmt":"2024-07-05T21:58:54","slug":"why-cant-i-drag-from-server-explorer-to-my-form","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/why-cant-i-drag-from-server-explorer-to-my-form\/","title":{"rendered":"Why can&#8217;t I drag from Server Explorer to my form?"},"content":{"rendered":"<p class=\"MsoNormal\"><span>This was one of the hardest decisions we had to make.<span>&nbsp; <\/span>We know this is a very intuitive way to work.<span>&nbsp; <\/span>I&rsquo;ve got my database, and I want it on my form (period).<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><b><span>Background<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><span>First, lets look at what we had in 2002, 2003.<span>&nbsp; <\/span>In 2003 you could drag from Server Explorer to your form, but we didn&rsquo;t give you textboxes and labels. <span>&nbsp;<\/span>We gave you an untyped, configured DataAdapter<\/p>\n<p><\/span><\/p>\n<ul type=\"disc\">\n<li class=\"MsoNormal\"><span>With the untyped, configured DataAdapter on the form, you then had to right click and choose Create DataSet. \n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>Then you had to make sure the [Create DataSet on my Form] was checked.\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>You had to choose to create a new dataset, or merge with an existing one.<span>&nbsp; <\/span>And of course the DataAdapter was named SqlDataAdapter5 and the DatSet was named DataSet3.<span>&nbsp; <\/span>Which was which&hellip;?\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>Now, you still don&rsquo;t have data bound controls.<span>&nbsp; <\/span>You now have to drag controls from the toolbox (both a data entry control such as a textbox and a label).<span>&nbsp; <\/span>You have to name them&hellip;\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>And then, you&rsquo;re still not done.<span>&nbsp; <\/span>You have to navigate through the property grid, expand the DataBindings section and select the DataSet and Column.<span>&nbsp; <\/span>DataSet3, DataSet2&hellip; ?\n<\/p>\n<p><\/span><\/li>\n<\/ul>\n<p class=\"MsoNormal\"><b><span>Whidbey<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><span>So, in comes Whidbey features where we now can create controls, labels, name them, and databind them.<span>&nbsp; <\/span>See the Sept\/October issue of <a href=\"http:\/\/www.code-magazine.com\/\">Code-Magazine.com<\/a> for my article on <a href=\"http:\/\/www.code-magazine.com\/Article.aspx?quickid=0409051\">Drag Once DataBinding<\/a>.<span>&nbsp; <\/span>Note: you do need to have a subscription to view the whole article, but hey, code is a great magazine <\/span><span><span>J<\/span><\/span><span><span>&nbsp; <\/span><i>Once an article is two months old, they open it up to the public&hellip;<\/i><\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><b><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>Here&rsquo;s the problem<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><span>In order to give a complete experience we&rsquo;re creating typed DataSets and Typed DataAdapters that are shared throughout the project.<span>&nbsp; <\/span><\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>Here&rsquo;s the scenario:<\/p>\n<p><\/span><\/p>\n<ul type=\"disc\">\n<li class=\"MsoNormal\"><span>Brand new project\n<\/p>\n<p><\/span><\/li>\n<\/ul>\n<ul type=\"disc\">\n<li class=\"MsoNormal\"><span>You create a connection to your database in Server Explorer\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>You then drag the Id and Name from the Customers table to Form1\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>You run the form and life is good.\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>You then create Form2 and all the columns and create a DataGridView\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>You press F5 and life seems good except you really don&rsquo;t want all 50,000 customers loaded into your form.<span>&nbsp;&nbsp; <\/span>So you change the default query on Form2 to load only those customers with a particular name WHERE Name LIKE @name.\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>Depending on where you&rsquo;ve done this, you will break Form1 as Form1 wasn&rsquo;t expecting to provide @name as a parameter.<span>&nbsp; <\/span>Form2 had additional columns which are now part of the schema of Form1 as well.\n<\/p>\n<p><\/span><\/li>\n<\/ul>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>When you dragged the columns from Server Explorer to your form, behind the scenes we created a Typed DataSet and a Typed DataAdapter.<span>&nbsp; <\/span>We then instance these on the form and databind controls to them.<span>&nbsp; <\/span><i>So far, so good.<\/i><span>&nbsp; <\/span><\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>When you dragged additional columns to Form2, we have a choice.<span>&nbsp; <\/span><\/p>\n<p><\/span><\/p>\n<ul type=\"disc\">\n<li class=\"MsoNormal\"><span>We could either create a 2<sup>nd<\/sup> dataset named NorthwindDataSet1 and thus pollute your project with a bunch of DataSets each time you drag to the form.\n<\/p>\n<p><\/span><\/li>\n<li class=\"MsoNormal\"><span>Or we could do what appears to be the smarter thing and merge the CustomerDataTable from Form1 with that of Form2.<span>&nbsp; <\/span>Of course we&rsquo;d merge the queries as well.<span>&nbsp; <\/span>The net affect of this is we&rsquo;ve actually changed what Form1 is working with.<span>&nbsp; <\/span>It now has additional columns, and the query may be changed as well.<span>&nbsp; <\/span>Would developers realize we were changing the classes that were instanced on other forms?<span>&nbsp; <\/span>If they didn&rsquo;t know this at first, what would they think when they figured this out.<span>&nbsp; <\/span>Would this be helpful, or magical stuff that developers didn&rsquo;t trust?\n<\/p>\n<p><\/span><\/li>\n<\/ul>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>We experimented with some dialogs prompting the user to help us make the right decision about merging or creating new datasets or datatables, but the experience just wasn&rsquo;t that great so we decided to just scale back.<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><b><span>The decision<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><span>So, ultimately, the entry points aren&rsquo;t as intuitive. <span>&nbsp;<\/span>&hellip;but we won&rsquo;t mess with your perfectly working forms as you continue to build the project.<span>&nbsp; <\/span>We should also keep in mind that while dragging from Server Explorer to the form is intuitive, it isn&rsquo;t as feature rich.<span>&nbsp; <\/span>For instance, developers don&rsquo;t have a way to choose their default control; Textbox, DateTimePicker, DataGridView, ComboBox or even their own custom control.<span>&nbsp; <\/span><\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>We did discuss merging much of the functionality from the Server Explorer with the Data Sources Window, but that would only be Database centric.<span>&nbsp; <\/span>Where would you drag Objects from?<span>&nbsp; <\/span>The most obvious is the class designer.<span>&nbsp; <\/span><i>So, then we wind up with anarchy&hellip;<\/i> I&rsquo;m dragging from everywhere.<span>&nbsp; <\/span>Gee, that actually sounds like what Microsoft would normally do. <\/span><span><span>J<\/span><\/span><span><span>&nbsp; <\/span>Seriously, that&rsquo;s actually a great idea, but it just wasn&rsquo;t feasible to get all this dev&rsquo;d and tested and still ship the features we have.<span>&nbsp; <\/span>It&rsquo;s also not necessarily the &ldquo;right&rdquo; thing to do in the big picture.<span>&nbsp; <\/span>If you look at the Data Sources Window, (especially when we ship Beta 2), compared to Server Explorer and the Class viewer, their each targeted at their basic usage design.<span>&nbsp; <\/span>It was far more controlled to create a single collection of Data Sources that we could put all the Custom Controls and Relation semantic in.<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><b><span>Explaining the Data Sources Window and Server Explorer<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><span>Think of Server Explorer as all the Databases within your enterprise across multiple departments.<span>&nbsp; <\/span>If your consultant, you might have Database connections for several customers. This list isn&rsquo;t specific to a project&hellip;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>Think of the Data Sources Window as what&rsquo;s available within a specific project.<span>&nbsp; <\/span>The &ldquo;shape&rdquo; of the DataSource may be different within your project then it exists at the source.<span>&nbsp; <\/span>For instance it&rsquo;s fairly common to join a table within a DataSet to list the Name as well as the foreign key id.<span>&nbsp; <\/span>The Server explorer would only show that if you had a View or Sproc.<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>With the above complications of expectation compared to our typed DataSets and DataAdapters we felt it was better to be more explicit then magical.<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>The expectation is developers will pull in Data Sources from their enterprise into the Data Sources Window.<span>&nbsp; <\/span>They may be database connections, queries, etc. from various different locations, object references from dll&rsquo;s from my company, or web services from around the world.<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>The Data Sources Window will consolidate all the available Data Sources for the active project.<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>Steve Lasker<\/span><span><\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>Program Manager <\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>Data Design-Time for Client Apps<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>Blogs @ http:\/\/blogs.msdn.com\/vbteam\/category\/4754.aspx<\/p>\n<p><\/span><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This was one of the hardest decisions we had to make.&nbsp; We know this is a very intuitive way to work.&nbsp; I&rsquo;ve got my database, and I want it on my form (period). Background First, lets look at what we had in 2002, 2003.&nbsp; In 2003 you could drag from Server Explorer to your form, [&hellip;]<\/p>\n","protected":false},"author":260,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[192,195],"tags":[],"class_list":["post-7363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-featured","category-visual-basic"],"acf":[],"blog_post_summary":"<p>This was one of the hardest decisions we had to make.&nbsp; We know this is a very intuitive way to work.&nbsp; I&rsquo;ve got my database, and I want it on my form (period). Background First, lets look at what we had in 2002, 2003.&nbsp; In 2003 you could drag from Server Explorer to your form, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/7363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/users\/260"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/comments?post=7363"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/7363\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media?parent=7363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=7363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=7363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}