am new with c# so plz be patient with me..
i have created a database and i wanna connect my application with it
while am searching i found this code:
using System;
using System.Data.Sql Client;
namespace ConsoleCSharp
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class DataReader_SQL
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
try
{
SqlConnection thisConnection = new SqlConnection(" Data Source=,1433;da tabase=Database 2;User id=;Password=;" );
SqlCommand thisCommand = thisConnection. CreateCommand() ;
thisCommand.Com mandText = "SELECT CustomerID, CompanyName FROM Customers";
SqlDataReader thisReader = thisCommand.Exe cuteReader();
while (thisReader.Rea d())
{
Console.WriteLi ne("\t{0}\t{1}" , thisReader["CustomerID "], thisReader["CompanyNam e"]);
}
thisReader.Clos e();
thisConnection. Close();
}
catch (SqlException e)
{
Console.WriteLi ne(e.Message);
}
}
}
}
so my question is how can i change the user id and password i have tried to
add the password in the xml configuration file however i still have exception
plz help me out i wanna knew how can i connect my application with the
database using the connection string
thanks alot
i have created a database and i wanna connect my application with it
while am searching i found this code:
using System;
using System.Data.Sql Client;
namespace ConsoleCSharp
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class DataReader_SQL
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
try
{
SqlConnection thisConnection = new SqlConnection(" Data Source=,1433;da tabase=Database 2;User id=;Password=;" );
SqlCommand thisCommand = thisConnection. CreateCommand() ;
thisCommand.Com mandText = "SELECT CustomerID, CompanyName FROM Customers";
SqlDataReader thisReader = thisCommand.Exe cuteReader();
while (thisReader.Rea d())
{
Console.WriteLi ne("\t{0}\t{1}" , thisReader["CustomerID "], thisReader["CompanyNam e"]);
}
thisReader.Clos e();
thisConnection. Close();
}
catch (SqlException e)
{
Console.WriteLi ne(e.Message);
}
}
}
}
so my question is how can i change the user id and password i have tried to
add the password in the xml configuration file however i still have exception
plz help me out i wanna knew how can i connect my application with the
database using the connection string
thanks alot
Comment