Thursday, August 16, 2007

USE Database
SELECT ColumnName
FROM Table
Group BY ColumnName
Having count(*) > 1

Monday, August 6, 2007

Copy a table from one database to another

There are many ways to copy a database table to an another database. Below you will find the simplest solution I found for myself.

SELECT *
INTO TargetDatabase.dbo.MyTable
FROM SourceDatabase.dbo.MyTable

del.icio.us Tags: ,,

Thursday, July 19, 2007

ASP GridView: Displaying the Summary Data in the Footer

It is many times necessary to display some additional data in the GridView's footer row. This task can be accomplished through the RowDataBound event handler.

protected void Gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
         if (e.Row.RowType == DataControlRowType.Footer) //if the row is footer
         {
                e.Row.Cells[3].Text = "Some text" ;
         }
}

del.icio.us Tags: ,,,

Tuesday, May 15, 2007

identity ID of the inserted row with TableAdapter.Insert()

Simple solution:

Select MAX(xxxID) From xxxTable

SOAP Request XML with User Credentials

private string SAR(XmlDocument requestXML, string webServiceName)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(webServiceBasePath + webServiceName);
request.Headers.Add("SOAPAction", webServiceBasePath + webServiceName);
request.Credentials = new NetworkCredential(kulAdi, kulSif);
request.ContentType = "text/xml";
request.Method = "POST";
request.Accept = "text/xml";
Stream stm = request.GetRequestStream();
stm.Write(System.Text.Encoding.ASCII.GetBytes(requestXML.InnerXml.ToString()), 0, requestXML.InnerXml.ToString().Length);
stm.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader r = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
return r.ReadToEnd();
}

Monday, May 14, 2007

ie6 ie7 CSS min-height problem

Different Internet explorer versions interpret CSS differently. One of the common problem is to set a minimum height for a tag or div section. Just setting up min-height property will not be enough because of the fact that ie6 does not have a support. Below you will find very simple workaround for the problem.

Solution:
min-height:600px;
height: auto;
height: 600px;

Now it works for both browsers.

Remote MS SQL Server connection with SQL Server Management Studio

If you have your database in a remote server, probably you would like connect to it from your computer directly and edit your databases rather than explicitly connecting to your remote computer via remote desktop connection. The advantage of this approach is, it is far away faster and you don't need to install any unnecessary database tools to your remote server.

Here is the very helpful article how to achieve this;
http://www.aquesthosting.com/HowTo/Sql2005/connect.aspx

How to bring print dialog with Javascript

Simple Solution:

(a href="Javascript:self.print()")Print this page(/a)

Print this page

Invalid postback or callback argument problem

Solution:

Nothing to do with enableEventValidation. Just dont forget if (!IsPostBack) in the Page_Load


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
}

Gridview, passing row index with CommandArgument

CommandArgument='%# DataBinder.Eval(Container, "RowIndex")%'

Note: Dont forget brackets.. Blog does nor allow to show them.

Gridview FindControl in Headerrow returns null problem

Sample solution:

(TextBox)this.GridView2.HeaderRow.FindControl(("TextboxID"));