Click here to Skip to main content
16,006,442 members
Home / Discussions / C#
   

C#

 
AnswerRe: Library Problem Pin
Christian Graus23-Jun-07 13:16
protectorChristian Graus23-Jun-07 13:16 
QuestionTyped Dataset Pin
TheEagle23-Jun-07 9:20
TheEagle23-Jun-07 9:20 
AnswerRe: Typed Dataset Pin
WillemM23-Jun-07 10:20
WillemM23-Jun-07 10:20 
GeneralRe: Typed Dataset Pin
TheEagle27-Jun-07 7:11
TheEagle27-Jun-07 7:11 
QuestionAdding new User to Windows XP ??? Pin
zinc_z23-Jun-07 8:18
zinc_z23-Jun-07 8:18 
AnswerRe: Adding new User to Windows XP ??? Pin
Giorgi Dalakishvili23-Jun-07 8:32
mentorGiorgi Dalakishvili23-Jun-07 8:32 
GeneralRe: Adding new User to Windows XP ??? [modified] Pin
zinc_z23-Jun-07 9:13
zinc_z23-Jun-07 9:13 
QuestionBeginning Databases Pin
alostdruid23-Jun-07 8:12
alostdruid23-Jun-07 8:12 
I'm trying to learn How to use Databases from a book,it gives me this code to input and it runs fine except it doesn't write any of the lines to the console as it should. I dont get any error messages. I moved some of the code around and the problem seems to be that it stops processing after the conn.Open() method. Anybody know why or how to fix it?

using System;
using System.Data;
using System.Data.SqlClient;

namespace Chapter04
{
class SqlServerProvider
{
static void Main(string[] args)
{
// Set up connection string
string connString = @"
server = .\sqlexpress;
integrated security = true;
database = northwind
";

// Set up query string
string sql = @"
select
*
from
employees
";

// Declare connection and data reader variables
SqlConnection conn = null;
SqlDataReader reader = null;

try
{
// Open connection
conn = new SqlConnection(connString);
conn.Open();

// Execute the query
SqlCommand cmd = new SqlCommand(sql, conn);
reader = cmd.ExecuteReader();

// Display output header
Console.WriteLine(
"This program demonstrates the use of "
+ "the SQL Server Data Provider."
);
Console.WriteLine(
"Querying database {0} with query {1}\n"
, conn.Database
, cmd.CommandText
);
Console.WriteLine("First Name\tLast Name\n");

// Process the result set
while(reader.Read()) {
Console.WriteLine(
"{0} | {1}"
, reader["FirstName"].ToString().PadLeft(10)
, reader[1].ToString().PadLeft(10)
);
}
}
catch (Exception e)
{
Console.WriteLine("Error: " + e);
}
finally
{
// Close connection
reader.Close();
conn.Close();
}
}
}
}

AnswerRe: Beginning Databases Pin
WillemM23-Jun-07 10:14
WillemM23-Jun-07 10:14 
QuestionXamlParseException whenever assigning values to C# class member Pin
Kris10023-Jun-07 7:23
Kris10023-Jun-07 7:23 
AnswerRe: XamlParseException whenever assigning values to C# class member Pin
Ed.Poore23-Jun-07 9:52
Ed.Poore23-Jun-07 9:52 
AnswerRe: XamlParseException whenever assigning values to C# class member Pin
WillemM23-Jun-07 10:16
WillemM23-Jun-07 10:16 
QuestionAbstract and inheriting Pin
Brendan Vogt23-Jun-07 7:04
Brendan Vogt23-Jun-07 7:04 
AnswerRe: Abstract and inheriting Pin
DavidNohejl23-Jun-07 7:16
DavidNohejl23-Jun-07 7:16 
AnswerRe: Abstract and inheriting Pin
Luc Pattyn23-Jun-07 9:16
sitebuilderLuc Pattyn23-Jun-07 9:16 
QuestionIs Unicode or not? Pin
Dominik Reichl23-Jun-07 5:56
Dominik Reichl23-Jun-07 5:56 
AnswerRe: Is Unicode or not? Pin
Giorgi Dalakishvili23-Jun-07 6:16
mentorGiorgi Dalakishvili23-Jun-07 6:16 
QuestionUpdate Database from DataSet Question Pin
Rick van Woudenberg23-Jun-07 1:59
Rick van Woudenberg23-Jun-07 1:59 
AnswerRe: Update Database from DataSet Question Pin
Luc Pattyn23-Jun-07 2:12
sitebuilderLuc Pattyn23-Jun-07 2:12 
AnswerRe: Update Database from DataSet Question Pin
PaulPrice23-Jun-07 2:25
PaulPrice23-Jun-07 2:25 
GeneralRe: Update Database from DataSet Question Pin
Rick van Woudenberg23-Jun-07 2:30
Rick van Woudenberg23-Jun-07 2:30 
GeneralRe: Update Database from DataSet Question Pin
Luc Pattyn23-Jun-07 2:46
sitebuilderLuc Pattyn23-Jun-07 2:46 
GeneralRe: Update Database from DataSet Question Pin
PaulPrice24-Jun-07 21:26
PaulPrice24-Jun-07 21:26 
Questionhow to use Rdlc Report to Run Time Pin
imran_Shaikh23-Jun-07 1:08
imran_Shaikh23-Jun-07 1:08 
QuestionCross development platform form embedding. Pin
daviiie23-Jun-07 0:20
daviiie23-Jun-07 0:20 

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.