|
Why don't they update ViewState to use generics?!?
/\ |_ E X E GG
|
|
|
|
|
|
I want to get
1. get some data using a SqlDataAdapter from a query on db
2. close connection from db
3. fill a dataset and bind it to a control.
4. making updates on data and post it back to db update all rows back.
but it must like saving an excel page. So what can be the best method. Is there anything like opposite action of a dataAdapter fill method.
<br />
SqlDataAdapter da; <br />
<br />
using (SqlConnection con = new SqlConnection(connectionString)) {<br />
cmd.Connection = con; <br />
con.Open();<br />
da = new SqlDataAdapter(cmd) <br />
}<br />
<br />
ds = new Dataset();<br />
da.Fill(ds)<br />
...<br />
<br />
<br />
karanba
|
|
|
|
|
well yes, da.Update(ds)
providing you specify an update command (i see you have specified a select command when initializing your data adapter)
---Guy H ( ---
|
|
|
|
|
Hi, I want to learn, which will be is true for best performance. Are those the same thing that not to close a connection and leave it to dispose when the scope finishes.
<br />
public static SqlDataAdapter getDataAdapter(SqlCommand cmd, string connectionString)<br />
{<br />
SqlConnection con = new SqlConnection(connectionString);<br />
cmd.Connection = con;<br />
con.Open();<br />
return new SqlDataAdapter(cmd);<br />
}
or
<br />
public static SqlDataAdapter dataAdapter(SqlCommand cmd, string connectionString)<br />
{<br />
SqlConnection con = new SqlConnection(connectionString);<br />
cmd.Connection = con;<br />
con.Open();<br />
SqlDataAdapter da = new SqlDataAdapter(cmd)<br />
con.Close();<br />
return da;<br />
}
karanba
|
|
|
|
|
You should definitely close the connection. If you don't, the connection object will be lying around in memory, still connected, until the garbage collector is forced to finalize it.
If you run out of available connections before you run out of memory (which will cause a garbage collection), the server will be unable to connect to the database at all until some of the open connections eventually time out.
Objects in .NET are not finalized when they go out of scope, they are just left to be garbage collected. That's why there is a Dispose method in the first place. It's used to tell objects that you are done with them, so that they can release all unmanaged resources.
To make sure that the connection is always closed properly, you should use a using block. When you leave the using block, the connection is always disposed (which also closes it).
public static SqlDataAdapter dataAdapter(SqlCommand cmd, string connectionString) {
SqlDataAdapter da;
using (SqlConnection con = new SqlConnection(connectionString)) {
cmd.Connection = con;
con.Open();
da = new SqlDataAdapter(cmd)
}
return da;
}
---
b { font-weight: normal; }
|
|
|
|
|
thanks a lot a get a clear answer.
karanba
|
|
|
|
|
Hi.
Can anyone give me an idea about it :
I want to make a picture gallery using ASP.Net2 (C#), that images are in DB.
I want using a control that has paging feature.
but Gridview is not sufficeint, because it has borders.
how can do it?
Best wishes
|
|
|
|
|
Hi..
use PagedDataSource class. Here an example that shows how to use an asp:Repeater with paging next and previus page
DataSet ds = new DataSet();<br />
da.Fill(ds);<br />
<br />
PagedDataSource pds = new PagedDataSource(); <br />
pds.DataSource = ds;<br />
pds.AllowPaging = true;<br />
pds.PageSize = 10; <br />
<br />
int CurPage; <br />
if (Request.QueryString["p"] != null) CurPage = Convert.ToInt32(Request.QueryString["p"]); <br />
else CurPage = 1;<br />
<br />
pds.CurrentPageIndex = CurPage-1;<br />
<br />
myRepeater.DataSource = pds;<br />
if (pds.Count > 0)<br />
{<br />
myRepeater.Visible = true;<br />
myRepeater.DataBind();<br />
}<br />
<br />
if (!pds.IsFirstPage) lnkPrev.HRef = "news.aspx?p=" + Convert.ToString(CurPage - 1);<br />
if (!pds.IsLastPage) lnkNext.HRef = "news.aspx?p=" + Convert.ToString(CurPage + 1);
if it is not clear you could ask for more..
karanba
|
|
|
|
|
Hi karanba,
I am not clear can you please send me a full code it is very urgent requirement.
My mail id : briteindia_kumar@hotmail.com
thanks and regards
kumar
|
|
|
|
|
i have this web.config (below) I have a list of user names and passwords in my sql server. How have the web.config link/check the tables of my sql server to authorize the username and password?
<configuration>
<system.web>
<authentication mode="Forms">
<authorization>
<deny users="?">
|
|
|
|
|
Doesn't anybody ever have a look at how their posting ended up?
Use the "Ignore HTML" option when you post XML code.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: Doesn't anybody ever have a look at how their posting ended up?
If half of em don't see "No programming questions in the lounge"......
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Is there a way to prevent Visual Studio 2005 from generating localized resources for some controls?
For example, I have a subset of controls that must not be localized, but Visual Studio keeps generating resources and adding the "meta" tag to those controls.
Thanks for any help.
|
|
|
|
|
Hi friends
i am creating chatting application.
Here i have some problem to create appliction.
i want to get alert message to server side when user enter in chat room
and name of user.
i want to store user name in some var and send this var to server side and when this var will come then automatically alert message should be appear on server.
PLZ give me right solution
Thanks a lots in advance
Pathan
|
|
|
|
|
What's wrong with a simple HTML form and a session variable?
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
But how can I read that var to server side and how can i get alert message?
Plz give me some solution or link , i have no any idea to use it
|
|
|
|
|
You can't display an alert message on the server, the server side of a web application doesn't have a user interface.
If you want a message on the server, you have to start a client on it so that you have a user interface, and poll the server for messages.
---
b { font-weight: normal; }
|
|
|
|
|
hi guys i need your advice again =)
i am currently doing a website that connect to an sql data base which works on my vb.net.
i am using sql server 2000 and vb.net 2003
i have recently decided to web host it however it doesnt work wit my existing web.config.
the below is an standard web.config i got from my web host could any one teach me the steps in configuring this pls i would be veri gratful.
www.duoultra.com/needhelp
|
|
|
|
|
hi there....
I have one label box, in that i want to display the current year.. how can i display.. Please help me.........
I used this, but it's not working...
Lbl_Year.Text = DateTime.Now.Year;
Advance n Thanks
Sam.M
|
|
|
|
|
Add ToString() at the end of Year.
And next time please define what you mean by "not working".
And check documentation to see what type does some function return so you don't assign integer to a text like you did here...
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
hi.........
I added ToString() at last of the year, but no value is showing in that label box.....
Is't Correct....
Lbl_Year.Text = DateTime.Now.Year.ToString();
Thks
Sam
|
|
|
|
|
Where do you have that code? In the Page_Load event?
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Hello,
Can you check in Page_load page.Databind() is there or not.
Regards,
S Kumar
|
|
|
|
|
S_kumarN wrote: Can you check in Page_load page.Databind() is there or not.
Eh... why would he?
It has nothing even remotely to do with the current question.
---
b { font-weight: normal; }
|
|
|
|