Fix a few code formatting issues in posts
This commit is contained in:
parent
e76d1caf8c
commit
9c4346157b
|
@ -11,17 +11,25 @@ categories = ["article", "technology"]
|
|||
tags = ["c#", "mssql", ".net"]
|
||||
+++
|
||||
|
||||
<p>In <a href="http://strivinglife.com/words/post/Programmatic-MSSQL-data-source-in-ASPNET-C-Sharp.aspx">a similar article</a> I detailed how I was doing programmatic access of Microsoft SQL Server. However, on another project I was creating a class in App_Code. Using my method required the use of a couple additional namespaces from System.Web. That seemed a bit excessive.</p>
|
||||
<p>So I did some digging around and came up with what I believe is a better solution, for use in classes/non-Web code.</p>
|
||||
<p>First, the following must be included in.</p>
|
||||
<pre class="code"><code class="csharp">// For DataTable
|
||||
In [a similar article](/post/programmatic-mssql-data-source-in-aspnet-c-sharp) I detailed how I was doing programmatic access of Microsoft SQL Server. However, on another project I was creating a class in App_Code. Using my method required the use of a couple additional namespaces from System.Web. That seemed a bit excessive.
|
||||
|
||||
So I did some digging around and came up with what I believe is a better solution, for use in classes/non-Web code.
|
||||
|
||||
First, the following must be included in.
|
||||
|
||||
```csharp
|
||||
// For DataTable
|
||||
using System.Data;
|
||||
// For SqlConnection, SqlCommand, SqlParameter, SqlDataAdapter
|
||||
using System.Data.SqlClient;
|
||||
// For ConfigurationManager
|
||||
using System.Configuration;</code></pre>
|
||||
<p>Next we have the code, with some dummy data.</p>
|
||||
<pre class="code"><code class="csharp">public DataTable returnDataTable(int Id) {
|
||||
using System.Configuration;
|
||||
```
|
||||
|
||||
Next we have the code, with some dummy data.
|
||||
|
||||
```csharp
|
||||
public DataTable returnDataTable(int Id) {
|
||||
DataTable returnValue = new DataTable();
|
||||
|
||||
SqlConnection connection = new SqlConnection();
|
||||
|
@ -40,6 +48,9 @@ using System.Configuration;</code></pre>
|
|||
connection = null;
|
||||
|
||||
return returnValue;
|
||||
}</code></pre>
|
||||
<p>This seems to be a bit better than what I had.</p>
|
||||
<p>Or not? Let me know.</p>
|
||||
}
|
||||
```
|
||||
|
||||
This seems to be a bit better than what I had.
|
||||
|
||||
Or not? Let me know.
|
||||
|
|
|
@ -11,9 +11,11 @@ categories = ["article", "technology"]
|
|||
tags = ["c#", "mssql", ".net"]
|
||||
+++
|
||||
|
||||
<p>I keep having to search through code to find it, so, since writing about it makes it easier for me to find ... here's how I've been programmatically making calls to Microsoft SQL Server.</p>
|
||||
<p>If I'm doing something wrong, please comment below or send me an email. Some times have been changed to dummy values.</p>
|
||||
<pre class="code"><code class="csharp">
|
||||
I keep having to search through code to find it, so, since writing about it makes it easier for me to find ... here's how I've been programmatically making calls to Microsoft SQL Server.
|
||||
|
||||
If I'm doing something wrong, please comment below or send me an email. Some times have been changed to dummy values.
|
||||
|
||||
```csharp
|
||||
SqlDataSource dataSource = new SqlDataSource();
|
||||
dataSource.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
|
||||
dataSource.SelectCommand = "stored_proc";
|
||||
|
@ -29,16 +31,22 @@ DataTable tableData = viewData.ToTable();
|
|||
tableData = null;
|
||||
viewData = null;
|
||||
dataSource = null;
|
||||
</code></pre>
|
||||
<p>From what I can tell, there's no close by doing a select this way; the connection must close after it's performed?</p>
|
||||
<h3>Update June 6 2009:</h3>
|
||||
<p>To use this code you would also need to include the following, if they were not already included.</p>
|
||||
<pre class="code"><code class="csharp">// Need to add for SqlDataSource
|
||||
```
|
||||
|
||||
From what I can tell, there's no close by doing a select this way; the connection must close after it's performed?
|
||||
|
||||
## Update June 6 2009:
|
||||
To use this code you would also need to include the following, if they were not already included.
|
||||
|
||||
```csharp
|
||||
// Need to add for SqlDataSource
|
||||
using System.Web.UI.WebControls;
|
||||
// Need for ConfigurationManager
|
||||
using System.Configuration;
|
||||
// Need for DataView
|
||||
using System.Data;
|
||||
// For DataSourceSelectArguments
|
||||
using System.Web.UI;</code></pre>
|
||||
<p>Because of this, there may be another way to do this, that doesn't require these additions.</p>
|
||||
using System.Web.UI;
|
||||
```
|
||||
|
||||
Because of this, there may be another way to do this, that doesn't require these additions.
|
||||
|
|
|
@ -11,13 +11,11 @@ categories = ["article"]
|
|||
tags = ["ubuntu", "postgresql"]
|
||||
+++
|
||||
|
||||
<p>
|
||||
Below are the PostgreSQL 8.2 commands on Ubuntu.<!--more-->
|
||||
</p>
|
||||
<p>
|
||||
|
||||
These are listed here primarily for my own benefit.
|
||||
</p>
|
||||
<pre>
|
||||
|
||||
```
|
||||
General
|
||||
\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]
|
||||
connect to new database (currently "template1")
|
||||
|
@ -32,8 +30,9 @@ set internal variable, or list all if no parameters
|
|||
\timing toggle timing of commands (currently off)
|
||||
\unset NAME unset (delete) internal variable
|
||||
\! [COMMAND] execute command in shell or start interactive shell
|
||||
</pre>
|
||||
<pre>
|
||||
```
|
||||
|
||||
```
|
||||
Query Buffer
|
||||
\e [FILE] edit the query buffer (or file) with external editor
|
||||
\g [FILE] send query buffer to server (and results to file or |pipe)
|
||||
|
@ -49,8 +48,9 @@ Input/Output
|
|||
\o [FILE] send all query results to file or |pipe
|
||||
\qecho [STRING]
|
||||
write string to query output stream (see \o)
|
||||
</pre>
|
||||
<pre>
|
||||
```
|
||||
|
||||
```
|
||||
Informational
|
||||
\d [NAME] describe table, index, sequence, or view
|
||||
\d{t|i|s|v|S} [PATTERN] (add "+" for more detail)
|
||||
|
@ -71,8 +71,9 @@ list tables/indexes/sequences/views/system tables
|
|||
\du [PATTERN] list users
|
||||
\l list all databases (add "+" for more detail)
|
||||
\z [PATTERN] list table, view, and sequence access privileges (same as \dp)
|
||||
</pre>
|
||||
<pre>
|
||||
```
|
||||
|
||||
```
|
||||
Formatting
|
||||
\a toggle between unaligned and aligned output mode
|
||||
\C [STRING] set table title, or unset if none
|
||||
|
@ -85,13 +86,13 @@ numericlocale|recordsep|tuples_only|title|tableattr|pager})
|
|||
\t show only rows (currently off)
|
||||
\T [STRING] set HTML <table> tag attributes, or unset if none
|
||||
\x toggle expanded output (currently off)
|
||||
</pre>
|
||||
<pre>
|
||||
```
|
||||
|
||||
```
|
||||
Copy, Large Object
|
||||
\copy ... perform SQL COPY with data stream to the client host
|
||||
\lo_export LOBOID FILE
|
||||
\lo_import FILE [COMMENT]
|
||||
\lo_list
|
||||
\lo_unlink LOBOID large object operations
|
||||
</pre>
|
||||
|
||||
```
|
||||
|
|
|
@ -11,14 +11,19 @@ categories = ["article", "tutorials / guides"]
|
|||
tags = ["ubuntu", "mysql", "postgresql"]
|
||||
+++
|
||||
|
||||
<p>Another Ubuntu Quickie, this time on the default passwords for MySQL and PostgreSQL.</p>
|
||||
<h3>MySQL</h3>
|
||||
<pre class="code"><code class="powershell">mysql -u root
|
||||
Another Ubuntu Quickie, this time on the default passwords for MySQL and PostgreSQL.
|
||||
|
||||
## MySQL
|
||||
```powershell
|
||||
mysql -u root
|
||||
UPDATE mysql.user SET Password = OLD_PASSWORD('***password***') WHERE User = 'root';
|
||||
FLUSH PRIVILEGES;
|
||||
\q</code></pre>
|
||||
<h3>PostgreSQL</h3>
|
||||
<pre class="code"><code class="powershell">
|
||||
\q
|
||||
```
|
||||
|
||||
## PostgreSQL
|
||||
```powershell
|
||||
sudo -u postgres psql template1
|
||||
ALTER USER postgres WITH PASSWORD '***password***';
|
||||
\q</code></pre>
|
||||
\q
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue