Wednesday, December 7, 2011

This Blog will completely started at January 1, 2012 Started this Blog to post Query and this blog provides you code samples and Sample projects…

 January 1, 2012 This blog Helps you to clear doughts in DOTNET, ANDROID, IPHONE ,JAVA AND PHP Codes…

For Clarification..

See My Site link given below.,

http://sureshkumara.blogspot.com/


DOT NET CONNECTION WITH DATABASE :

This below sample code will connect you with ASP Dot Net to SQL Database..

VB Code:


Dim newConnection As SqlClient.SqlConnection
                newConnection = New SqlClient.SqlConnection("server=SEVER;uid=User_ID;pwd=PASSWORD;database=DATABASE_NAME")
                newConnection.Open()                                                      Dim dataReader As SqlClient.SqlDataReader                                                 Dim newCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand("Command Here")         dataReader = newCommand.ExecuteReader()                                                   GridView1.DataSource = dataReader                                                         GridView1.DataBind()


C# Code:

SqlConnection newConnection = New SqlConnection();
newConnection.ConnectionString ="server=SEVER;uid=User_ID;pwd=PASSWORD;database=DATABASE_NAME";                                                                                                    newConnection.Open();                                                      SqlDataReader dataReader = New SqlDataReader();                                           SqlCommand newCommand = New SqlCommand("Command Here");                                   dataReader = newCommand.ExecuteReader();                                                  GridView1.DataSource = dataReader;                                                        GridView1.DataBind();


This below sample code will connect you with ASP Dot Net to Access Database..


VB Code:


Dim DbConnection As New OleDbConnection()
                DbConnection.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;User Id=;Password=;Data Source=C:\\Database\SwCompany.mdb"
        DbConnection.Open()
        Dim dtLoadData As New DataTable
        Dim da As New OleDbDataAdapter()
        da = New OleDbDataAdapter("SELECT * FROM EMPLOYEE", DbConnection)
        da.Fill(dtLoadData)
        GridView1.DataSource = dtLoadData                                                         GridView1.DataBind()                                                                      DbConnection.Close()


C# Code:

OleDbConnection DbConnection = New OleDbConnection;
DbConnection.ConnectionString ="server=SEVER;uid=User_ID;pwd=PASSWORD;database=DATABASE_NAME";                                                                                              DbConnection.Open();                                                                      DataTable dtLoadData = new DataTable();                                                   OleDbDataAdapter da = new OleDbDataAdapter("Command / Query Here",DbConnection);          da.Fill(dtLoadData);                                                                      GridView1.DataSource = dtLoadData;                                                        GridView1.DataBind();                                                                     DbConnection.Close();



Note: The above code is same for connecting Window and Web based Applications
















This Blog will completely started at January 1, 2012 Started this Blog to post Query and this blog provides you code samples and Sample projects…

 January 1, 2012 This blog Helps you to clear doughts in DOTNET, ANDROID, IPHONE ,JAVA AND PHP Codes…

For Clarification..

See My Site link given below.,

http://sureshkumara.blogspot.com/