Click here to Skip to main content
15,890,527 members
Home / Discussions / C#
   

C#

 
QuestionSerialPort Class with RS485 Pin
stancrm8-May-09 3:23
stancrm8-May-09 3:23 
AnswerRe: SerialPort Class with RS485 Pin
Dave Kreskowiak8-May-09 4:52
mveDave Kreskowiak8-May-09 4:52 
Questionreading data from biomatrix machine Pin
nikhil12348-May-09 2:50
nikhil12348-May-09 2:50 
AnswerRe: reading data from biomatrix machine Pin
Jimmanuel8-May-09 3:02
Jimmanuel8-May-09 3:02 
Question[Message Deleted] Pin
hkjghkj18-May-09 2:48
hkjghkj18-May-09 2:48 
AnswerRe: PictureBox Stretch Image Pin
Dave Kreskowiak8-May-09 4:48
mveDave Kreskowiak8-May-09 4:48 
QuestionCrystal report - how to take combo box at discrete value Pin
KIDYA8-May-09 2:28
KIDYA8-May-09 2:28 
QuestionNullReferenceException object reference not set to an instance of an object..please help Pin
bobolov8-May-09 2:20
bobolov8-May-09 2:20 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using Microsoft.AnalysisServices;
using Microsoft.DataWarehouse.Interfaces;
using System.Data.OleDb;
using System.Data.Common;



namespace DatabaseApplication
{
public partial class Form1 : Form
{
string dbname;
string connectionstring;
string databasename;
string datasourceviewname;
string datasourcename;
string tableName;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
string connstring = "Data Source=localhost;Integrated Security=True";

SqlConnection connection = new SqlConnection(connstring);

string query = "select * from sys.databases";

SqlDataAdapter data = new SqlDataAdapter(query, connection);

DataTable dtable = new DataTable();

try
{
connection.Open();
int records = data.Fill(dtable);
if (records > 0)
{
foreach (DataRow dr in dtable.Rows)
{
//Console.WriteLine(dr[0]);
comboBox1.Items.Add(dr[0]);
}
}
}
catch (SqlException sqlexcp)
{
MessageBox.Show("connection error");
}


}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
dbname = comboBox1.Text;
}

private void button1_Click(object sender, EventArgs e)
{
/*databasename = dbname;
datasourceviewname = "oor";
connectionstring = "Data Source=localhost;Integrated Security=True";

//create a datasource name
RelationalDataSource newDS = new RelationalDataSource(datasourceviewname, Utils.GetSyntacticallyValidID(datasourceviewname, typeof(RelationalDataSource)));

Database db = new Database("oor");

db.DataSources.Add(newDS);

newDS.ConnectionString = connectionstring;

newDS.Update();*/


Server server = new Server();

databasename = "cwh_temp";

server.Connect("localhost"); // connection to the MS Analysis service engine

Database db = new Database(databasename, Utils.GetSyntacticallyValidID(databasename, typeof(Database)));


if (server.Databases.ContainsName(databasename))
server.Databases.RemoveAt(server.Databases.IndexOfName(databasename));

server.Databases.Add(db);

db.Update();

connectionstring = "Provider=SQLNCLI.1;Data Source=localhost;Integrated Security=SSPI;Initial Catalog=rmcwh_alevoor";
datasourcename = "ooru";

RelationalDataSource dsNew = new RelationalDataSource(datasourcename, Utils.GetSyntacticallyValidID(datasourcename, typeof(RelationalDataSource)));

db.DataSources.Add(dsNew);

dsNew.ConnectionString = connectionstring;

dsNew.Update();

datasourceviewname = "ooru";

DataSourceView dsv;

dsv = db.DataSourceViews.Add(datasourceviewname, Utils.GetSyntacticallyValidID(datasourceviewname, typeof(DataSourceView)));

dsv.DataSourceID = dsNew.ID;

OleDbConnection cn = new OleDbConnection(dsNew.ConnectionString);

tableName = "UdayPareekScale";

//dss.Tables[1].TableName = "Folder";
try
{

OleDbCommand cmd = new OleDbCommand("Select * from [" + tableName + "]", cn);

OleDbDataAdapter ad = new OleDbDataAdapter(cmd);

DataSet dss = new DataSet();

ad.FillSchema(dss, SchemaType.Source);

dss.Tables[0].TableName = tableName;

dsv.Schema.Tables.Add(dss.Tables[tableName].Clone());
}
catch (NullReferenceException nre)
{
MessageBox.Show(nre.ToString());
}
catch(Exception exp)
{
MessageBox.Show(exp.ToString());
}

//dsv.Schema.Tables.Add(dss.Tables["Folder"].Clone());

dsv.Update();
}
}
}
AnswerRe: NullReferenceException object reference not set to an instance of an object..please help Pin
tom5720078-May-09 2:23
tom5720078-May-09 2:23 
GeneralRe: NullReferenceException object reference not set to an instance of an object..please help Pin
bobolov8-May-09 2:50
bobolov8-May-09 2:50 
GeneralRe: NullReferenceException object reference not set to an instance of an object..please help Pin
Dave Kreskowiak8-May-09 4:46
mveDave Kreskowiak8-May-09 4:46 
GeneralRe: NullReferenceException object reference not set to an instance of an object..please help Pin
bobolov8-May-09 6:26
bobolov8-May-09 6:26 
GeneralRe: NullReferenceException object reference not set to an instance of an object..please help Pin
Luc Pattyn8-May-09 5:05
sitebuilderLuc Pattyn8-May-09 5:05 
QuestionCalling a function Pin
sachees1238-May-09 2:15
sachees1238-May-09 2:15 
AnswerRe: Calling a function Pin
tom5720078-May-09 2:22
tom5720078-May-09 2:22 
AnswerRe: Calling a function Pin
musefan8-May-09 2:25
musefan8-May-09 2:25 
GeneralRe: Calling a function Pin
sachees1238-May-09 3:00
sachees1238-May-09 3:00 
AnswerRe: Calling a function Pin
Rajesh Anuhya8-May-09 3:11
professionalRajesh Anuhya8-May-09 3:11 
GeneralRe: Calling a function Pin
sachees1238-May-09 3:17
sachees1238-May-09 3:17 
GeneralRe: Calling a function Pin
Rajesh Anuhya8-May-09 3:23
professionalRajesh Anuhya8-May-09 3:23 
GeneralRe: Calling a function Pin
sachees1238-May-09 3:49
sachees1238-May-09 3:49 
AnswerRe: Calling a function Pin
harold aptroot8-May-09 3:46
harold aptroot8-May-09 3:46 
Questioncreation of sql server view in a windows based application c# Pin
mariamkhaqan8-May-09 2:02
mariamkhaqan8-May-09 2:02 
AnswerRe: creation of sql server view in a windows based application c# Pin
Dave Kreskowiak8-May-09 4:44
mveDave Kreskowiak8-May-09 4:44 
QuestionHow can we Identify the tab that is active among all the tabs in IE7 Pin
svt gdwl8-May-09 2:01
svt gdwl8-May-09 2:01 

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.