Skip to main content

Posts

Showing posts from 2013

Linked Server No transaction active. Unable to start distributed transaction

In case you receive this error while running a transaction on the linked server, don't panic. This is caused by the RPC Endpoint Mapper service. Although this service is started by default on the Windows server, but still it may not work properly. Because of this, the App servers may not contact the database server. Though lot of solutions have been provided for removing this error on internet which works on Component Services Settings, but nothing works. So to remove this error, just reboot the server (linked). Its a simple fix, though you have to restart the server but it definitely works.

Get Details about SQL Server TempDB Database MDF and LDF Files and Change the Path of these files

In order to check the details about the SQL Server TempDB database MDF and LDF files, we can use the following command: USE tempdb EXEC sp_helpfile GO This will return details about SQL Server TempDB MDF and LDF files as given in the below screenshot:       The details are the default values that are used by SQL Server for the TempDB, in case we have not changed at the time of installation. In case we want to change the path and file name, we can use the following command: USE master GO ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev , FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\tempdb_new.mdf' ) GO ALTER DATABASE tempdb MODIFY FILE ( NAME = templog , FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\templog_new.ldf' ) GO The above will change the path and names of the TempDB MDF and LDF files. But in order to actually come in

Attendance Saving Code Demo

For all students who wanted a Demo of Saving Attendance in the table. protected void Button1_Click( object sender, EventArgs e)     {         //ON THE CLICK OF SAVE ATTENDANCE BUTTON         DateTime vDt = DateTime .Now;         int vRegNo;         String vCourseCode;         String vSection;         String vAttendanceStatus = "" ;         for ( int x = 0; x < GridView1.Rows.Count; x++)         {             vRegNo = Convert .ToInt16(GridView1.Rows[x].Cells[0].Text);             vCourseCode = GridView1.Rows[x].Cells[1].Text;             vSection = GridView1.Rows[x].Cells[2].Text;             DropDownList temp = ( DropDownList )GridView1.Rows[x].Cells[3].FindControl( "mydropdown" );             if (temp.SelectedIndex == 0)             {                 vAttendanceStatus = "P" ;             }             else if (temp.SelectedIndex == 1)             {                  vAttendanceStatus = &qu

Offline or Disconnected Database Access

The following code shows how to use insert, delete and update in the Offline method of ADO.NET. With the help of ADO.NET we use the techniqueS of DataSet, DataAdapter, DataRowCollection, DataRow, DataColumn etc. for working with the database. //FOR INSERTION IN DATABASE SqlConnection conn = new SqlConnection ( "Server=(local);DataBase=Rohit;Integrated Security=SSPI" );             conn.Open();             SqlDataAdapter vAdap = new SqlDataAdapter ( "Select * from empNew" , conn);             DataSet vDs = new DataSet ();             vAdap.Fill(vDs, "EmpNew" );             DataTable vDt = vDs.Tables[ "EmpNew" ];             DataRow vDr = vDt.NewRow();             vDr[ "Empno" ] = Convert .ToInt32(textBox1.Text);             vDr[ "Ename" ] = textBox2.Text;             vDr[ "Salary" ] = Convert .ToInt32(textBox3.Text);             vDt.Rows.Add(vDr);             //Now w