Click here to Skip to main content
16,005,037 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can i Apply theme at runtime Pin
Anthony Mushrow7-Dec-07 15:11
professionalAnthony Mushrow7-Dec-07 15:11 
Generalcomparing two arrays Pin
rameshdontagani6-Dec-07 17:50
rameshdontagani6-Dec-07 17:50 
GeneralRe: comparing two arrays Pin
Sathesh Sakthivel6-Dec-07 17:52
Sathesh Sakthivel6-Dec-07 17:52 
GeneralRe: comparing two arrays Pin
rameshdontagani6-Dec-07 18:05
rameshdontagani6-Dec-07 18:05 
GeneralProblem in CheckedLitBox Pin
chanzeb6-Dec-07 17:47
chanzeb6-Dec-07 17:47 
GeneralRe: Help meeeee!!!! Pin
Sathesh Sakthivel6-Dec-07 17:51
Sathesh Sakthivel6-Dec-07 17:51 
GeneralRe: Help meeeee!!!! Pin
Abhijit Jana6-Dec-07 18:02
professionalAbhijit Jana6-Dec-07 18:02 
QuestionNew to C# .Problem while accessing sql server Pin
mohanallam6-Dec-07 17:28
mohanallam6-Dec-07 17:28 
Hi friends

I am facing a problem while accessing database sqlserver 2005 from command prompt.
Here i am giving my code. I don't have any compilation errors,
But runtime errors as follows....

Unhandled Exception: System.Data.SqlClient.SqlException: An error has occurred w
hile establishing a connection to the server. When connecting to SQL Server 200
5, this failure may be caused by the fact that under the default settings SQL Se
rver does not allow remote connections. (provider: Named Pipes Provider, error:
40 - Could not open a connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception

my code is :

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

/// <summary>
/// Demonstrates how to work with SqlConnection objects
/// </summary>
class SqlConnectionDemo
{
static void Main()
{
// 1. Instantiate the connection

string strConnection = "server=localhost; Trusted_Connection=yes; timeout=120";
SqlConnection Conn = new SqlConnection(strConnection);

SqlDataReader rdr = null;

try
{
// 2. Open the connection
if (Conn.State == ConnectionState.Closed)
{
Conn.Open();
}


// 3. Pass the connection to a command object
SqlCommand cmd = new SqlCommand("select * from Customers", Conn);


// 4. Use the connection


// get query results
rdr = cmd.ExecuteReader();

// print the CustomerID of each record
while (rdr.Read())
{
Console.WriteLine(rdr[0]);
}
}
finally
{
// close the reader
if (rdr != null)
{
rdr.Close();
}

// 5. Close the connection
if (Conn != null)
{
Conn.Close();
}
}
}
}
Note: I am executing my program at cmd prompt.

Help please...........
GeneralRe: New to C# .Problem while accessing sql server Pin
I.explore.code6-Dec-07 17:43
I.explore.code6-Dec-07 17:43 
GeneralRe: New to C# .Problem while accessing sql server Pin
mohanallam7-Dec-07 16:54
mohanallam7-Dec-07 16:54 
GeneralSetting value in installer and reading at runtime Pin
atuldeore6-Dec-07 17:26
atuldeore6-Dec-07 17:26 
GeneralRe: Setting value in installer and reading at runtime Pin
Jacky Yiu6-Dec-07 17:48
Jacky Yiu6-Dec-07 17:48 
GeneralRe: Setting value in installer and reading at runtime Pin
I.explore.code6-Dec-07 17:52
I.explore.code6-Dec-07 17:52 
Generalquestion on database query Pin
angels7776-Dec-07 16:57
angels7776-Dec-07 16:57 
GeneralRe: question on database query Pin
Jacky Yiu6-Dec-07 17:44
Jacky Yiu6-Dec-07 17:44 
GeneralRe: question on database query Pin
angels7776-Dec-07 18:06
angels7776-Dec-07 18:06 
GeneralRe: question on database query Pin
Jacky Yiu6-Dec-07 22:15
Jacky Yiu6-Dec-07 22:15 
GeneralRe: question on database query Pin
angels7776-Dec-07 23:09
angels7776-Dec-07 23:09 
GeneralRe: question on database query Pin
angels7777-Dec-07 19:50
angels7777-Dec-07 19:50 
GeneralRe: question on database query Pin
angels7779-Dec-07 0:43
angels7779-Dec-07 0:43 
GeneralRe: question on database query Pin
Jacky Yiu9-Dec-07 15:11
Jacky Yiu9-Dec-07 15:11 
Generalwhy update data is wrong.. Pin
angels7776-Dec-07 16:33
angels7776-Dec-07 16:33 
GeneralRe: why update data is wrong.. Pin
Jacky Yiu6-Dec-07 17:36
Jacky Yiu6-Dec-07 17:36 
GeneralRe: why update data is wrong.. Pin
angels7776-Dec-07 18:18
angels7776-Dec-07 18:18 
GeneralRe: why update data is wrong.. Pin
angels7776-Dec-07 18:55
angels7776-Dec-07 18:55 

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.