Showing posts with label solve. Show all posts
Showing posts with label solve. Show all posts

Thursday, March 22, 2012

Errot :can not connect to server

i am getting error to connect C#.net with sql server. how to solve the problem?

frstly check u hv written proper code and given proper path to ur database..

i hv a copy of it. see this.. this may help

using System.Data.SqlClient;

SqlConnection myConnection = new SqlConnection("user id=username;" +
"password=password;server=serverurl;" +
"Trusted_Connection=yes;" +
"database=database; " +
"connection timeout=30");

try
{
myConnection.Open();
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}

myCommand.Connection = myConnection;

myCommand.CommandText = "ur query"

myCommand.ExecuteNonQuery();

try
{
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select * from table",
myConnection);
myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
Console.WriteLine(myReader["Column1"].ToString());
Console.WriteLine(myReader["Column2"].ToString());
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}

Wednesday, March 7, 2012

Error1'System.Net.NetworkCredential' is a 'type', which is not valid in the given contextC:\

Hello, I got this error when trying to render, in the line of the credentials, how should I solve it.

rs.Credentials = System.Net.NetworkCredential("levalencia", "123", "se");

ReportingService2005 rs;

private void cargarReporteFromWS()

{

rs = new ReportingService2005();

rs.Credentials = System.Net.NetworkCredential("levalencia", "123123123", "se");

}

Hello,

System.Net.NetworkCredential is not a static method, but a constructor, so you need to use the "new" keyword.

rs.Credentials = new System.Net.NetworkCredential("levalencia", "123", "se");