|
hello
I am new in ASP.NET , and im going to create a simple website , but just need to use SQL as database to store datas.
i couldn't find information about how to start to connect to Database .
I installed SQL2005 express , and Web Matrix , i first created a new project , then i clicked "Data"-->>"SQL...", after it told me can not connect to SQL server , may i know whether i am in a right step ?
Thanks!
|
|
|
|
|
|
Thanks!
|
|
|
|
|
Dear All,
In download data module of my application(with asp.net2.0/sqlserver2005)one of the function is returning a datareader object having 7 hundererd thousands plus record. It returns the datareader without an exception but when i am iterating through the datareader to take its values to a string bulider type varible to write a csv file, it throws an 'System.OutOfMemoryException' due to huge records. I can not filter the record as it is required to write a csv file of the whole data. how can i avoide this error and improve the efficency of the system so that it takes less resources. The compilation debug is set to false. Also when there a few hundered thousand records the download is working ok. Thanks in advance for the help form any esteemed member.
Thanks,
Safvi
|
|
|
|
|
public static string WriteCSVFilebyDataReader(SqlDataReader SqlDataReaderObject)
{
StringBuilder strResult = new StringBuilder();
try
{
for (int i = 0; i < SqlDataReaderObject.FieldCount; i++)
{
strResult.Append("\" " + SqlDataReaderObject.GetName(i) + " \",");
}
strResult.Append("\n");
if (SqlDataReaderObject.HasRows)
{
while (SqlDataReaderObject.Read())
{
for (int j = 0; j < SqlDataReaderObject.FieldCount; j++)
{
strResult.Append("\"" +SqlDataReaderObject.GetValue(j).ToString() + "\",");
}
strResult.Append("\n");
//SqlDataReaderObject.NextResult();
}
}
}
catch (Exception ex)
{
throw ex;
}
return strResult.ToString();
}
|
|
|
|
|
When you use a datareader, data is not fetched from the database until you use the Read() method to read the next row, therefore you may not receive an error when you open the datareader. The problem seems to be with StringBuilder. You can split the result into batches of say 10000 rows and then write them. For example, open the csv file write 10000 rows, close it, then append the next 10000 rows and so on. You could do this using a loop counter. Each batch would use a new StringBuilder instance to write to the csv file.
|
|
|
|
|
Hi everyone,
Please read the xml file below. Thanks.
(1). Given id="100" and quantity=2. id="100" exists in the xml file. Then update quantity (i.e., 1+2 = 3) in the xml file.
(2). Given id="300" and quantity=1. id="300" does not exist in the xml file,
then insert this new record (i.e., <item id="300"><itemName>Bike</itemName><price>150.99</price><quantity>1</quantity></item>)
into the xml file.
(3). Given id="200". id="200" exist, then delete this record (<item id="200"><itemName>Car</itemName><price>99.99</price><quantity>1</quantity></item>)
<products>
<item id="100">
<itemName>Car</itemName>
<price>99.99</price>
<quantity>1<quantity>
</item>
<item id="200">
<itemName>Car</itemName>>
<price>99.99</price>
<quantity>1</quantity>
</item>
</products>
iam writing code in vb.net but i cont
please help me,
Can I have some sample code
Thanks,
modified on Tuesday, November 3, 2009 9:26 AM
|
|
|
|
|
|
|
pramodgorityala wrote: Can I have some sample code
Let's save you some time and trouble. Give us the email address of your teacher and we'll send the solution direct to him.
|
|
|
|
|
Welcome to the ASP.NET forum....
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi all,
I have an asp.net page ,contains 3 textboxes ,1 dropdownlis,1 button.
I have written the code for inserting data to the database inn the button click event.Its working properly,and cleared the textbox datas.
But after inserting the datas, I clear the texts in the textboxes and set visible=false.
Afetr this I tried to refresh the page,the above textbox values are again inserted into the database.
If somebody knows about this ,pls help me.
Thanks and Regards
Denny
|
|
|
|
|
TextBox.Text=""; to clear data in text box...
|
|
|
|
|
I have done already but still prob
|
|
|
|
|
The postback data won't be cleared and when you refresh, it will be resend. To work around this, consider redirecting the page after insert.
Response.Redirect("success.aspx")
Best wishes,
Navaneeth
|
|
|
|
|
but sir,i have a grid in that page and i want to show the values in the grid
|
|
|
|
|
This is the way ASP.NET postback works. When you refresh, your browser submits the same page with the same postback information. The only way you can avoid it is by redirecting it to a different page.
|
|
|
|
|
|
What do you mean when you say 'refresh the page?' How, exactly, are you doing that?
Ignore any answers that suggest that viewstate will not contain the latest value inserted into a textbox, including string.empty.
Without seeing rhe code it's hard to know, but it sounds like you may be rebinding those textboxes to your datastore.
|
|
|
|
|
What is the best approach to persist a dataset across postbacks so that users could manipulate the data in it and could be saved(to the database) at last.
|
|
|
|
|
You can put it in ViewState .
Best wishes,
Navaneeth
|
|
|
|
|
I am using ViewState now but I notice the page is slower during reloads
|
|
|
|
|
You can use viewstate, but if the size of the dataset is very large, it will bloat the request and response size and can probably kill your app. Use a DataTable object and persist it in session. You can also try serializing the object to a database and save the key in viewstate. Each approach has its own advantages and disadvantages. You should try to find out what works best for you.
|
|
|
|
|
Hello Shameel
How about persisting the DataSet(as I have more than one DataTable) in a Session variable and clearing it(using Session.Remove()) while the user navigates away from the page?
|
|
|
|
|
The best way is not to Persist the dataset ever. Just save the changes during postbacks and show the most recent data.
Remember, the user might go next page on next date. Or might be there is a session timeout. If you store everything in context, that means errors might loose everything.
|
|
|
|