Lance Larsen - .NET Architect Madison Wisconsin

All posts in SQL

imageFYI – here’s a trick so we don’t need to specify our local computer’s name in our web.config connectionString – because if you have multiple developers working on the same code – they each have to have different web.config versions with their individual computer names.

Generally we see…

<connectionStrings>
     <add name=”MyContext” connectionString=”Data Source=MYCOMPUTER; Initial Catalog=MyDatabase; Integrated Security=True; MultipleActiveResultSets=True” providerName=”System.Data.SqlClient” />
</connectionStrings>

What we want…

<connectionStrings>
    <add name=”MyContext” connectionString=”Data Source=.; Initial Catalog=MyDatabase; Integrated Security=True; MultipleActiveResultSets=True” providerName=”System.Data.SqlClient” />
</connectionStrings>



How?

1) Open your “Sql Server Configuration Manager” application.
2) Expand your “Sql Server Network Configuration”.
3) Right-click on “TCP/IP”.
4) Scroll down to “TCP Dynamic Ports” (which will be blank by default) and enter “0” which enables it. 
5) Restart your SQL service and you’re DONE!

Thanks Travis Feirtag (@therobotgeek) for this trick!


mysqlAs a primarily Microsoft SQL Server developer, when playing around with MySQL database ( specifically using MySQL Workbench ) wanted to be able to press F5 to execute the SQL commands that I was writing, by default you need to press Control-Enter or Control-Shift-Enter – but there is no GUI interface to remap keys shortcuts like there is in most Microsoft programs… so… found that the following worked and wanted to share!

Locate your “main_menu.xml” MySQL configuration file – mine was in “C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.6\data\main_menu.xml”.  Find the following XML.
 

   1:  <value type="object" struct-name="app.MenuItem" id="com.mysql.wb.menu.query.execute_current_statementwin"> 
   2:    <link type="object" key="owner" struct-name="app.MenuItem">com.mysql.wb.menu.query</link> 
   3:    <value type="string" key="caption">Execute Current Statement</value> 
   4:    <value type="string" key="name">query.execute_current_statement</value> 
   5:    <value type="string" key="command">builtin:query.execute_current_statement</value> 
   6:    <value type="string" key="itemType">action</value> 
   7:    <value type="string" key="shortcut">Modifier+Return</value>
   8:    <value type="string" key="platform">windows</value>
   9:  </value> 

Replace the “shortcut” xml (line 7 above) with the following, exit and reopen MySQL Workbench – and you’re rocking with F5!

<value type="string" key="shortcut">F5</value>