Click here to Skip to main content
15,918,193 members
Home / Discussions / Database
   

Database

 
Questioninset a Datacolumn Pin
PaulaM2-Sep-05 3:23
PaulaM2-Sep-05 3:23 
AnswerRe: inset a Datacolumn Pin
Besinci2-Sep-05 9:37
Besinci2-Sep-05 9:37 
Questionupdating the DB Pin
minkinin2-Sep-05 3:16
minkinin2-Sep-05 3:16 
AnswerRe: updating the DB Pin
Besinci2-Sep-05 10:04
Besinci2-Sep-05 10:04 
GeneralRe: updating the DB Pin
minkinin4-Sep-05 20:20
minkinin4-Sep-05 20:20 
GeneralRe: updating the DB Pin
Besinci4-Sep-05 21:24
Besinci4-Sep-05 21:24 
GeneralRe: updating the DB Pin
minkinin4-Sep-05 22:27
minkinin4-Sep-05 22:27 
GeneralRe: updating the DB Pin
Besinci5-Sep-05 7:49
Besinci5-Sep-05 7:49 
Here you go Smile | :) this will do it..


using System;

namespace Tester
{
///
/// Summary description for Class2.
///

public class Class1
{

public Class1()
{

}

public void GenerateColumns(System.Data.SqlClient.SqlConnection connection)
{
string selectstr = "SELECT name FROM sysobjects WHERE xtype ='U' AND name <> 'dtproperties' ORDER BY name";//select only user tables
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(selectstr, connection);
cmd.Connection = connection;

cmd.Connection.Open();
System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
this.AddColumn(dr.GetString(0), cmd.Connection.ConnectionString);
}
cmd.Connection.Close();
}

private void AddColumn(string tableName, string connnectionStr)
{
//ALTER TABLE table ADD column VARCHAR(20) NULL
string alterTableStr = string.Format("ALTER TABLE {0} ADD {1} {2} {3}", tableName, "YourColumnName", "datetime Default getdate()", "NULL");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(alterTableStr, new System.Data.SqlClient.SqlConnection(connnectionStr));
try
{
cmd.Connection.Open();
cmd.ExecuteNonQuery();
}
catch(System.Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
finally
{
cmd.Connection.Close();
}
}
}
}






-- modified at 14:02 Monday 5th September, 2005
GeneralRe: updating the DB Pin
minkinin6-Sep-05 23:38
minkinin6-Sep-05 23:38 
QuestionI need to load custom data to Analysis Server (MS-OLAP) without going through any OLE DB Provider. Pin
kuldeepjangir2-Sep-05 3:13
kuldeepjangir2-Sep-05 3:13 
QuestionSqlDataAdapter question.. What.... Pin
Besinci2-Sep-05 2:40
Besinci2-Sep-05 2:40 
AnswerRe: SqlDataAdapter question.. What.... Pin
Luis Alonso Ramos2-Sep-05 17:26
Luis Alonso Ramos2-Sep-05 17:26 
GeneralRe: SqlDataAdapter question.. What.... Pin
Besinci3-Sep-05 2:06
Besinci3-Sep-05 2:06 
GeneralRe: SqlDataAdapter question.. What.... Pin
Luis Alonso Ramos3-Sep-05 6:28
Luis Alonso Ramos3-Sep-05 6:28 
QuestionDatabinding Problem In My UserControl Pin
User 20930732-Sep-05 2:39
User 20930732-Sep-05 2:39 
QuestionI want to add,delete,save my project ... Pin
mostafa_h1-Sep-05 23:07
mostafa_h1-Sep-05 23:07 
QuestionHow will I know that DSN is not pointing to any database? Pin
PrashantJ1-Sep-05 21:17
PrashantJ1-Sep-05 21:17 
AnswerRe: How will I know that DSN is not pointing to any database? Pin
Michael Potter2-Sep-05 5:25
Michael Potter2-Sep-05 5:25 
QuestionData Isolation and Transaction Isolation Pin
devvvy1-Sep-05 17:37
devvvy1-Sep-05 17:37 
AnswerRe: Data Isolation and Transaction Isolation Pin
airbus3801-Sep-05 22:14
airbus3801-Sep-05 22:14 
GeneralRe: Data Isolation and Transaction Isolation Pin
devvvy1-Sep-05 22:21
devvvy1-Sep-05 22:21 
GeneralRe: Data Isolation and Transaction Isolation Pin
airbus3802-Sep-05 0:42
airbus3802-Sep-05 0:42 
General"Data Isolation" Vs "Locking" Pin
devvvy3-Sep-05 21:33
devvvy3-Sep-05 21:33 
QuestionHOW I KNOW WHAT TABLES ARE IN A DATA BASE IN CSHARP Pin
alonso2k811-Sep-05 10:40
alonso2k811-Sep-05 10:40 
AnswerRe: HOW I KNOW WHAT TABLES ARE IN A DATA BASE IN CSHARP Pin
Michael P Butler1-Sep-05 11:21
Michael P Butler1-Sep-05 11:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.