There are 2 tables in “GoodCompany” database “Customers” and “Sales”. You have a valid connection string called “MyConnection” with default database set to “GoodCompany”.
“Customers” has “CustID” as primary key/identity and “FullName” field.
“Sales” has “ProdID” as primary key/identity, “ProductName”, and “CustID” that is foreign key to the “Customers” table.
SELECT CustID, FullName, ProdID, ProductName
FROM Customers c, Sales s
WHERE c.CustID = s.CustID
Please do the following using ADO.NET:
Create a Stored Procedure that takes CustID as a parameter and returns all Sales for that customer along with Customer’s name.
Explain how to populate a GridView with this data.
SEE my answer in the Details section... Is is right?How to implement stored procedure using ADO.NET?
Looks correct to me. A little tip: when populating stored procedure parameters, I find this syntax more readable:
command.Parameters.Add(';@CustID';, SqlDbType.NVarChar).Value = custID
This way you can declare the parameter, its type and set its value all on one line.
Wednesday, August 18, 2010
How to refresh entire page after gridview is updated?
when i updated a row in gridview, or delete a row from gridview, onli the gridview is updated. however any codes outside of gridview will not be refreshed.
lets say i have a gridview with productname, price,etc
and a label that displays the Total sum of everything thats in the cart, calling on the method Total()
however whenever i update or delete something from gridview, only gridview changes. the total only changes once i REFRESH that page manually myself. how do i enable the page to do a refresh whenever a change is done to gridview?How to refresh entire page after gridview is updated?
Encapsulate the logic that refreshes them in functions. Obviously the code that refreshes them is there in your code, but its not being called after you update your GridView.
After updating your Gridview, call the functions that refresh the controls in the page which you wish to refresh.
Hope this helps.How to refresh entire page after gridview is updated?
What program are you in?web hosting talk loan
lets say i have a gridview with productname, price,etc
and a label that displays the Total sum of everything thats in the cart, calling on the method Total()
however whenever i update or delete something from gridview, only gridview changes. the total only changes once i REFRESH that page manually myself. how do i enable the page to do a refresh whenever a change is done to gridview?How to refresh entire page after gridview is updated?
Encapsulate the logic that refreshes them in functions. Obviously the code that refreshes them is there in your code, but its not being called after you update your GridView.
After updating your Gridview, call the functions that refresh the controls in the page which you wish to refresh.
Hope this helps.How to refresh entire page after gridview is updated?
What program are you in?
How to display a message box when gridview_RowDeleting event performs?
MessageBox.Show(...)
Loren Soth
Loren Soth
ASP.NET how do I customize a dynamic data web site?
I have gotten my data displayed properly in scaffolds but I would like to rearrange gridview columns for some tables and add some formatting for the resulting data. Also, I want to change the view for inserting items ... and... Sometimes on table joins, it displays the wrong column. How can I change how the data is displayed for an individual table?
To summarize:
ASP.NET
SQL Server
LINQ to SQL connection and pulling the correct data
Using a dynamic data web site with scaffold all tables = TRUE in the global.asax...now I want to customize the look and feel of particular tables that get scaffolded.ASP.NET how do I customize a dynamic data web site?
Set the gridview to no autogeneratecolumns=';false'; and set the binding yourself.
To summarize:
ASP.NET
SQL Server
LINQ to SQL connection and pulling the correct data
Using a dynamic data web site with scaffold all tables = TRUE in the global.asax...now I want to customize the look and feel of particular tables that get scaffolded.ASP.NET how do I customize a dynamic data web site?
Set the gridview to no autogeneratecolumns=';false'; and set the binding yourself.
I have written a store procedure in sql server, and i have connected the sqlserver to .net, ?
I wrote this code in win app :
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@';Data Source=.;Initial Catalog=MyDB;Integrated Security=True';);
SqlCommand cmd = new SqlCommand(';hi';, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
dataGridView1.DataSource = dr;//give data to gridview
// I dont know what should i write here to bind data
dr.NextResult();
}
and i dont know how can i bind data in win app , but in asp.net we can use this statement :gridview1.databind();I have written a store procedure in sql server, and i have connected the sqlserver to .net, ?
try here sqldatadaptor,dataset in place of datareader
u cant bind DGV1 with datareader.
dim ad as sqldataadaptor=new sqldataadaptor
ad.selectcommand=cmd
dim ds as dataset=new dataset
ad.fill(ds,';tablename';)
dataGridView1.DataSource = ds.tables(0)
whole code is
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@';Data Source=.;Initial Catalog=MyDB;Integrated Security=True';;)
cmd=new sqlcommand
cmd.connection=SqlConnection con
cmd.commandtext=';name of stored procedure';
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection.Open();
dim ad as sqldataadaptor=new sqldataadaptor
ad.selectcommand=cmd
dim ds as dataset=new dataset
ad.fill(ds,';tablename';)
dataGridView1.DataSource = ds.tables(0)
Any error . u can ask
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@';Data Source=.;Initial Catalog=MyDB;Integrated Security=True';);
SqlCommand cmd = new SqlCommand(';hi';, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
dataGridView1.DataSource = dr;//give data to gridview
// I dont know what should i write here to bind data
dr.NextResult();
}
and i dont know how can i bind data in win app , but in asp.net we can use this statement :gridview1.databind();I have written a store procedure in sql server, and i have connected the sqlserver to .net, ?
try here sqldatadaptor,dataset in place of datareader
u cant bind DGV1 with datareader.
dim ad as sqldataadaptor=new sqldataadaptor
ad.selectcommand=cmd
dim ds as dataset=new dataset
ad.fill(ds,';tablename';)
dataGridView1.DataSource = ds.tables(0)
whole code is
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@';Data Source=.;Initial Catalog=MyDB;Integrated Security=True';;)
cmd=new sqlcommand
cmd.connection=SqlConnection con
cmd.commandtext=';name of stored procedure';
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection.Open();
dim ad as sqldataadaptor=new sqldataadaptor
ad.selectcommand=cmd
dim ds as dataset=new dataset
ad.fill(ds,';tablename';)
dataGridView1.DataSource = ds.tables(0)
Any error . u can ask
Where do i learn asp.net?
Dear friends
i have installed visual studio 2005 with oracle as back end. I work with C# codings. I am totally new. But capable of building projects at smaller levels. i need to learn the use of each and every control used in asp.net . I am capable of connecting to oracle and i can also save, update , delete , search records and i too know the basic use of gridview control. I have worked entirely using condings. A sample is given below
public partial class _Default : System.Web.UI.Page
{
public OracleCommand cmd;
public OracleDataAdapter da;
public OracleDataReader dr;
public DataSet ds;
public OracleConnection con;
string Strconnection = ConfigurationSettings.AppSettings[';Conne鈥?br>
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
string query;
con = new OracleConnection(Strconnection);
con.Open();
query = ';insert into t1(id,name) values('; + txtId.Text + ';,''; + txtName.Text + ';')';;
OracleCommand cmd = new OracleCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
lb1.Text = ';Record inserted Successfully';;
}
catch
{
lb1.Text = ';No record inserted';;
}
finally
{
con.Close();
}
}
How do i go head with other controls. I want to know the usage of all controls through codings only. Where i learn. Is there any one to teach me online or through phone. Am i using ASP 2.0 in visual studio 2005? i dont know this. What is the frame work used in visual studio 2005. Guide me...Where do i learn asp.net?
Use torent and download tutorial from lynda.comWhere do i learn asp.net?
You are using ASP.NET 2.0 (generally) in Visual Studio 2005, Visual Studio 2008 defaults to .NET 3.0 or 3.5 I think. A good book which is really cheap to have as a reference on ASP.NET is Wrox's Professional ASP.NET 2.0 (http://product.half.ebay.com/Professiona鈥?/a> It's ';obsolete'; therefor cheap :) and still very useful. It'll cover a lot of standard topics like user management, profile management, database connectivity, master pages, Javascript Callbacks (although I prefer AJAX and webservices now), XML webservices, and so on.
Try checking out this website; http://w3schools.com/aspnet/default.asp it will be a great way to start.
i have installed visual studio 2005 with oracle as back end. I work with C# codings. I am totally new. But capable of building projects at smaller levels. i need to learn the use of each and every control used in asp.net . I am capable of connecting to oracle and i can also save, update , delete , search records and i too know the basic use of gridview control. I have worked entirely using condings. A sample is given below
public partial class _Default : System.Web.UI.Page
{
public OracleCommand cmd;
public OracleDataAdapter da;
public OracleDataReader dr;
public DataSet ds;
public OracleConnection con;
string Strconnection = ConfigurationSettings.AppSettings[';Conne鈥?br>
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
string query;
con = new OracleConnection(Strconnection);
con.Open();
query = ';insert into t1(id,name) values('; + txtId.Text + ';,''; + txtName.Text + ';')';;
OracleCommand cmd = new OracleCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
lb1.Text = ';Record inserted Successfully';;
}
catch
{
lb1.Text = ';No record inserted';;
}
finally
{
con.Close();
}
}
How do i go head with other controls. I want to know the usage of all controls through codings only. Where i learn. Is there any one to teach me online or through phone. Am i using ASP 2.0 in visual studio 2005? i dont know this. What is the frame work used in visual studio 2005. Guide me...Where do i learn asp.net?
Use torent and download tutorial from lynda.comWhere do i learn asp.net?
You are using ASP.NET 2.0 (generally) in Visual Studio 2005, Visual Studio 2008 defaults to .NET 3.0 or 3.5 I think. A good book which is really cheap to have as a reference on ASP.NET is Wrox's Professional ASP.NET 2.0 (http://product.half.ebay.com/Professiona鈥?/a> It's ';obsolete'; therefor cheap :) and still very useful. It'll cover a lot of standard topics like user management, profile management, database connectivity, master pages, Javascript Callbacks (although I prefer AJAX and webservices now), XML webservices, and so on.
Try checking out this website; http://w3schools.com/aspnet/default.asp it will be a great way to start.
I want to know how store and retrive images through Asp.net in Sql server 2005, ??
Hey friends i want to know HOw store images like gif, jpeg,png file in sql server 2005 database? using Asp.net in c# or Vb.net whatever? and how to retrive it from sql server into asp.net web page as well as the image control and gridview control also? actually i m a student and i doing one project so i need some help pls guid me .... thanx for your any replyI want to know how store and retrive images through Asp.net in Sql server 2005, ??
SQL server has a data type called image, when you create the table you can enter that as the field type... alternately you can store the path to the images in which case you need to use nvarchar(1000)
And the rest, use the sqlconnection data type.I want to know how store and retrive images through Asp.net in Sql server 2005, ??
This page pretty much says how to do it.
http://www.asp.net/learn/data-access/tut鈥?/a>
SQL server has a data type called image, when you create the table you can enter that as the field type... alternately you can store the path to the images in which case you need to use nvarchar(1000)
And the rest, use the sqlconnection data type.I want to know how store and retrive images through Asp.net in Sql server 2005, ??
This page pretty much says how to do it.
http://www.asp.net/learn/data-access/tut鈥?/a>
Subscribe to:
Posts (Atom)