17 May 2010

Stored Procedure with parameter in C# with Sql Server for Insertion

Stored Procedure with parameter in C# with Sql Server for Insertion

Consider Table name:sampletable

field

username nvarchar(50)
mark1 int


Write it in Stored Procedure [if you create table first time, Then it automatically changed to alter]Procedure name-InsertUser


ALTER PROCEDURE [dbo].[InsertUser]
(
@username varchar(50),
@mark1 int
)
AS
INSERT INTO sampletable VALUES(@username, @mark1)


Coding in C#

protected void Button1_Click(object sender, EventArgs e)
{
string username=(TextBox1.Text);
string mark=(TextBox2.Text);
SqlConnection myConnection = new SqlConnection("user id=userid;" + "password=pwd;" + "Data source=localhost;" + "Integrated security=true;" + "database=sample;");
SqlCommand myCommand = new SqlCommand("InsertUser", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add("@username", SqlDbType.VarChar).Value = username;
myCommand.Parameters.Add("@mark1", SqlDbType.Int).Value = mark;
myConnection.Open();
int rows = myCommand.ExecuteNonQuery();
myConnection.Close();
}

Grid view in asp.net, C# using sql server

Grid view in asp.net, C# using sql server
protected void Button3_Click(object sender, EventArgs e)
{
SqlConnection myConnection = new SqlConnection("user id=userid;" + "password=pwd;" + "Data source=localhost;" + "Integrated security=true;" + "database=connectivitydb;");
try
{
myConnection.Open();
}
catch (Exception f)
{
Console.WriteLine(f.ToString());
}
try
{
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da = new SqlDataAdapter("select * from agedetail", myConnection);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
catch (Exception f)
{
Console.WriteLine(f.ToString());
}
}

royalarun.blogspot.com by ArunPrakash

15 May 2010

Asp.net, C# Connectivity with Sql server



using System.Data.SqlClient;
protected void Button1_Click(object sender, EventArgs e)

{

SqlConnection myConnection = new SqlConnection("user id=userid;" + "password=pwd;" + "Data source=localhost;" + "Integrated security=true;" + "database=connectivitydb;");
try
{
myConnection.Open();
}
catch (Exception f)
{
Console.WriteLine(f.ToString());
}
SqlCommand myCommand = new SqlCommand("Command String", myConnection);
myCommand.CommandText = ("INSERT into agedetail(name,age)" + values('ramasamy',24)");
myCommand.ExecuteNonQuery();
try{
myConnection.Close();
}
catch (Exception f)
{
Console.WriteLine(f.ToString());
}

Asp.net, C# Connectivity with Sql server



using System.Data.SqlClient;
protected void Button1_Click(object sender, EventArgs e)

{

SqlConnection myConnection = new SqlConnection("user id=userid;" + "password=pwd;" + "Data source=localhost;" + "Integrated security=true;" + "database=connectivitydb;");
try
{
myConnection.Open();
}
catch (Exception f)
{
Console.WriteLine(f.ToString());
}
SqlCommand myCommand = new SqlCommand("Command String", myConnection);

//myCommand.Connection = myConnection;
myCommand.CommandText = ("INSERT into agedetail(name,age)" + "values('ramasamy',24)");
myCommand.ExecuteNonQuery();
try
{
myConnection.Close();
}
catch (Exception f)
{
Console.WriteLine(f.ToString());
}
}

Puzzle:a candle, a wood stove and a gas lamp

If you are in a dark room with a candle, a wood stove and a gas lamp you only have one match what do you light first?

Guess?

?


?



?


?


?


Answer


you would have to light the match box first

Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...