Showing posts with label insert into. Show all posts
Showing posts with label insert into. Show all posts

My Google Ad isn't showing in my blog - FIX

Let's fix that critter. You'll also learn how to create a new

My Google Adsense in my other blog THINGS WE LOVE TO HATE isn't showing. It's supposed to be a banner on the bottom, my leaderboard on top and my box on the right panel are both working fine. The last thing I did (yesterday) was change the ad because it was the wrong size - from a leader board, I changed it into a banner. It wasn't showing yesterday also, but I thought it was only a system lag. So now I'm fixing it and I'll teach you how to do it on your own too (stop bothering the Google Adsense people, they're busy, too, you know).

BTW, this ad was made on the Google Adsense page - I didn't just add a Google Adsense through the ADD GADGET button on the Layout page. I created it on my Google Adsense page alongside a channel so I can monitor its performance - tell me if you need help setting this up.

Go to your Google Adsense Page: Adsense Setup tab then Preview the specific ad that's missing on your blog.

Guess what! It's STILL the wrong size. Stupid me.

Since we can't edit adsense sizes, I'll just hit this with the HIDE option (we also can't delete them), then I'll create a new one with the same name.

Set up the preferences - I created my own color scheme/panel according to my blog color motifs so I won't have to manually set it up all the time.

Make sure you have the right size, it's very first drop down box in this page and it's SO EASY to miss.

Then that's it. Choose a channel if you want to then you get the code and put it in your blog.

Mygad that sounded like a cheap shot at a tutorial.

Anyway, leave a comment if you need any help.

A call for underrepresented individuals

My friend is currently working on her thesis and she's having a hard time locating her subjects.

It's a photographic essay on twenty underrepresented individuals who have proved to play significant roles in society. These individuals’ greatness are not recognized because they do not fit the canonical standard typical of choosing who is worthy of recognition.

This group includes (but is not limited to) the poor or working class, the old people, the women, the homosexuals, the political deviants, the ethnic minorities and the handicapped. This could be a burnt child who saved his family from a burning house, a mother who single-handedly raised her six children while balancing three jobs at the same time, an old woman who despite her age serves as her family's breadwinner or an Ifugao elder from Cordillera who despite the changing trends in their culture brought about by modernization, continues to protect the dying art of tattooing.

A side note:
...I was wondering if Database admins are underrepresented individuals. Database admins always serve as the scape goat in companies - when something doesn't work right, they point their finger at the database admin. It's not like SQL Server Transactions are the only problem that exists.

How to copy SQL table content into INSERT INTO statements in SQL Server using SQL CLR

Most of the time during the database development stage of a specific system, programmers concerned with the different aspects of the system work all at the same time. While the Database Admin fine tunes the data structure including its constraints, metadata, relationships, views, stored procedures, the Data Access Layer Man has already started working on his end of the fence. He determines the anchor or the point of access, which table would most efficiently access all other related information. He makes sure that when data is inserted, deleted, updated then all other related information, all other related tables to that specific data are updated appropriately.

While the Data Access Layer is working on those delicate and logic intensive information, he has to have access to the database. However, the Database Admin is still working on the database itself. Since the Data Access Layer especially when done in an Entity Data Model (.NET Entity Framework) is sensitive to the stability of the information in the database, it is not wise if they were to connect to the same database.

In most business practices, the Data Access Layer team/man is given only a copy of the original database being developed. When a significant change was made to the database, he rebuilds his Entity Data Model accordingly. This is a tough job but it’s the only way to work at the same time with the DBA and therefore deliver faster. Sometimes the DAL would request the DBA to insert sample data within the database so that he may test his scripts against the database. But since they are physically connected to different databases, the DBA fixes SQL Script of Insert statements for him.

On the occasion when the DAL actually inserts his own table rows and the Web Dev man sees that there is already enough structure for him to connect his application and to test some of its units, he would need a copy of that database. It easy to script the database structure including its triggers and content to create it in a different local machine, however, when the database is already running in a different local machine and all the Web Dev needs is the rows to check if he can successfully display the table rows, let’s not waste time dropping and recreating databases.

Click to download code.

using System;

using System.Data;

using System.Data.SqlClient;

using System.Data.SqlTypes;

using Microsoft.SqlServer.Server;

using System.Text;

using System.Collections.Generic;

public partial class StoredProcedures

{

[Microsoft.SqlServer.Server.SqlProcedure]

public static void CopyContentOfTable(String tablename)

{

using (SqlConnection conn = new SqlConnection("context connection=true"))

{

conn.Open();

SqlCommand cmd = new SqlCommand();

cmd.Connection = conn;

StringBuilder sb = new StringBuilder();

sb.Append("SELECT column_name FROM information_schema.columns ")

.Append("WHERE table_name = '").Append(tablename).Append("'");

cmd.CommandText = sb.ToString();

//List down all the colum names in the table

List<String> columnames = new List<String>();

SqlDataReader reader;

using (reader = cmd.ExecuteReader())

{

if( reader.HasRows )

while (reader.Read())

{

columnames.Add(reader["column_name"].ToString());

}

}

//get all data from table

sb.Length = 0;

sb.Append("SELECT * from ").Append(tablename);

cmd.CommandText = sb.ToString();

//define needed logical objects for creating the insert statement

String columnvalue = String.Empty;

bool notfirstcolumn = false;

bool notfirstrow = false;

using (reader = cmd.ExecuteReader())

{

sb.Length = 0;

//Enable inserting identity,

//we want to make sure that the databases are as identical as possible

sb.Append("SET IDENTITY_INSERT ").Append(tablename).AppendLine(" ON;");

//you may turn off any related triggers if you wish to here...

//Build our insert statements

sb.Append("INSERT into ").Append(tablename).AppendLine(" (");

//list down all column names

foreach( String column in columnames)

{

if(notfirstcolumn)

sb.Append(",");

else

notfirstcolumn = true;

sb.Append(column);

}

//add each row, result from the previous SELECT transaction

notfirstcolumn = false;

sb.AppendLine(") VALUES ");

if (reader.HasRows)

while (reader.Read())

{

if (notfirstrow)

sb.Append(",");

else

notfirstrow = true;

sb.Append("(");

foreach (String column in columnames)

{

if (notfirstcolumn)

sb.Append(",");

else

notfirstcolumn = true;

columnvalue = reader[column].ToString();

if (columnvalue.Equals(String.Empty))

sb.Append("NULL");

else

sb.Append(columnvalue);

}

sb.AppendLine(")");

notfirstcolumn = false;

}

//re-disable indentity inserts

sb.Append("SET IDENTITY_INSERT ").Append(tablename).Append(" OFF;");

}

//Your insert statement will appear in the Message tab of the query window.

//Copy and paste it onto the query window and run

SqlContext.Pipe.Send(sb.ToString());

}

}

};