Arrays - One Dimensional
|
Arrays have 2 basic operations i.e. extraction and storing values.
|
C Language Code: |
ARRAY1D.H |
#include "assert.h" intarr *makearray(int n) void input(intarr *a1,int val, int pos) int get(intarr *a1,int pos) void printarray(intarr *a1,int posupto) //DISPLAYS THE ARRAY BEFORE SORTING printf("\n"); void sortarray(intarr *a1) for(i=0;i<a1->size-1;+i++) } |
ARRAY1D.CPP |
#include <stdio.h> void main() sortarray(a1) ; |
We are trying to contribute to the net what ever Technical knowledge. I Believe that knowledge increases by spreading and sharing with others.
Tuesday, January 30, 2024
Arrays - One Dimensional - DSTC using C Language (Source Code Implemented)
Rational Numbers (Abstract Data Type) - DSTC using C Language
Rational Numbers (Abstract Data Type) |
Consider the ADT Rational, which is a Mathematical concept of a rational number. A rational number is a number that can be expressed as the quotient of two integers. Operations to be performed for implemented Rational numbers are:
|
C Language Code: |
RATIONAL.H |
typedef struct rational rat *makerat(int a,int b) rat *sumrat(rat *x, rat *y) void killrat(rat *n) void printrat(rat *n) rat *reducerat(rat *r) for(;i>1;i--) return(t);
rat *subtractrat(rat *x, rat *y) Get Paid by Reading Ads on your Mobiles rat *multiplyrat(rat *x, rat *y) rat *dividerat(rat *x, rat *y) void ratequal(rat *x, rat *y) } |
RATIONAL.CPP |
#include <stdio.h> void main() printf("\n Enter 2st num and denomentor(n/d):"); // SUM OF Rational nos. printf("\n Display Two Rational No.s sum "); //********* SUBSTRATION OF 2 RATIONAL NOS. q = subtractrat(m,n); printf("\n Display Two Rational No.s Subtraction "); printrat(q) ; killrat(m) ; } |
Tuesday, January 24, 2023
How do I Insert data in SQL Server using ASP .Net
To insert data into a SQL Server database using ASP.NET, you can use the ADO.NET library to establish a connection to the database and execute an INSERT statement. Here is an example of how to do this:
1. Create a new ASP.NET project and add a reference to the System.Data.SqlClient namespace.
2. Create a new method that will handle the insertion of data.
3. In this method, create a new SqlConnection object and set the connection string to the appropriate value for your SQL Server database.
4. Open the connection using the Open() method.
5. Create a new SqlCommand object and set the CommandText property to the INSERT statement you want to execute.
6. Add any necessary parameters to the SqlCommand object using the Parameters.Add() method.
7. Execute the command using the ExecuteNonQuery() method.
8. Close the connection using the Close() method.
Here is an example of how your code might look:
using (SqlConnection con = new SqlConnection("Data Source=myServer;Initial Catalog=myDB;User ID=myUsername;Password=myPassword"))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("INSERT INTO myTable (col1, col2) VALUES (@val1, @val2)", con))
{
cmd.Parameters.AddWithValue("@val1", "some value");
cmd.Parameters.AddWithValue("@val2", 123);
cmd.ExecuteNonQuery();
}
con.Close();
}
How do I retrieve data from SQL Server using ASP .Net
In order to retrieve data from a SQL Server database in an ASP.NET application, you can use ADO.NET, which is a set of classes that provide data access services for the .NET Framework. The most commonly used classes for this purpose are the SqlConnection, SqlCommand, and SqlDataReader classes.
Here is an example of how you can use these classes to retrieve data from a SQL Server database and display it in an ASP.NET page:
Create a new SqlConnection object and set its connection string to the appropriate value for your SQL Server database.
Create a new SqlCommand object and set its CommandText property to the SQL query you want to execute.
Open the SqlConnection.
Execute the query by calling the ExecuteReader method of the SqlCommand object and store the result in a SqlDataReader object.
Iterate through the SqlDataReader object and retrieve the data you need.
Close the SqlConnection and SqlDataReader.
Here is an example of the above steps
Sample Code:
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Customers", con))
{
con.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
// Retrieve data from the reader
string name = reader["Name"].ToString();
string city = reader["City"].ToString();
// Do something with the data
}
}
con.Close();
}
}
It's also important to consider that this is just a simple example, and in production applications, you should handle exceptions, use parameters to avoid SQL injection, and dispose objects properly.
Thursday, December 3, 2020
How to Shrink SQL Server Database Log File Size using DBCC Command
How to Shrink SQL Server Database Log File Size using DBCC Command
you must take a full backup of your database before executing the following:
ALTER DATABASE <YOUR DATABASE NAME>
SET RECOVERY SIMPLE
GO
DBCC SHRINKFILE (<YOUR DATABASE LOG FILE NAME>, TARGET SIZE IN MB)
GO
ALTER DATABASE <YOUR DATABASE NAME>
SET RECOVERY FULL
Wednesday, April 24, 2019
Reset Windows 2008 R2 Server Admin password
- Boot from the Micrsoft Windows Server 2008 DVD
- From the Install Windows menu, click “Next”.
- Select “Repair your computer”
- In the System Recovery Options, select the Operating System instance that you wish to repair and click “Next”.
- Select “Command Prompt”. The
- At the command prompt, run the following commands:c:
cd windows\system32
ren Utilman.exe Utilman.exe.old
copy cmd.exe Utilman.exe - Reboot the server allowing Windows to load as normal
- At the logon screen, press Windows Key + U.
- As the command prompt, enter the following command:
- net user administrator New_PASSWORD
- Log into the server with New_PASSWORD
- Reboot into the repair command prompt
del utilman.exe
copy Utilman.exe.old utilman.exe
Thursday, May 10, 2018
ASP .NET AJAX - Maintain Or Set Page Scroll Position After Asynchronous Postback In ASP.NET AJAX
Now just add the below JavaScript code to the relevant section of your Web Page.
- <script type="text/javascript">
- var xPos, yPos, needScroll;
- var prm = Sys.WebForms.PageRequestManager.getInstance();
- prm.add_beginRequest(BeginRequestHandler);
- prm.add_pageLoaded(EndRequestHandler)
- function BeginRequestHandler(sender, args) {
- xPos = 0;
- yPos = window.pageYOffset || document.documentElement.scrollTop;
- }
- function EndRequestHandler(sender, args) {
- if (needScroll) {
- window.setTimeout("window.scrollTo(" + xPos + "," + yPos + ")", 100);
- }
- }
- </script>
After adding the above code at page script Tag on your code behind you need to add the below code at your .cs page to call the Javascript function after page completes its rendering after postback.
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ScrollTo", "var needScroll = true;", true);