|
http://gridviewguy.com/Articles.aspx?articleCategoryID=7
|
|
|
|
|
Dear Friends,
I need to submit a request from a client which will be save in my MS Access database by asp.net. can some one please give me the sample code to submit a request form by asp.net.
Your quick response will be highly appreciated.
Thanks
Murtuza Patel
|
|
|
|
|
|
What I need is a simple way to add a new record to my database based on the data collected in my web site.
I have create an aspx form (vwd express) with several text boxes and a button.
I'd like that clicking the button will create a new record in my database (mdb) wit h the text entered in the texts box as the new record fields values.
|
|
|
|
|
Lots of things you could do. You could:
- use an AccessDataSource control on your page, including an InsertCommand, establishing ControlParameters tied to your text boxes; then code the button to execute the AccessDataSource control's .Insert() method...
- create a custom class that handles your data access; in it, create an .Insert() method of your own that accepts two parameters; use OleDbConnection, OleDbCommand, and OleDbParameter classes to issue the SQL INSERT statement to your database; then code the button to execute the .Insert() method in your custom class...
- create the custom class as before, then use an ObjectDataSource on your page with the associated class. In your button's code, execute the .Insert() method on the ObjectDataSource...
- create a custom class and ObjectDataSource as before, and substitute for your existing textboxes/button a FormView or DetailsView control. Associate the FormView/DetailsView to your ObjectDataSource through the DataSourceID property, and let it handle all the data access for you...
- for that matter, you could associate an AccessDataSource to a FormView or DetailsView as well, and not use a custom class (or coding at all)...
But it sounds like you're very new to this. I'd recommend you go through the QuickStart Tutorials on http://www.asp.net[^] in depth. You'll get to some good exercises on data access. Look at the beginner's videos too - http://msdn.microsoft.com/vstudio/express/vwd/learning/default.aspx[^]
|
|
|
|
|
I am a n0ob to web programming
Recently i created my own web control. I want to make it so that i will recieve arguments like
<.uc1:treeFrame ID="TreeFrame1" runat= "server" argument1= "blah1" argument2= "blah2"/> (remove the "." in front of uc1)
contructors? in the treeFrame class?
also..
when i add my own user control to a html page by dragging it onto the designer, it puts this at the top of the html
<%@ Register Src="treeFrame.ascx" TagName="treeFrame" TagPrefix="uc1" %>
what does this do?
thx thx
-- modified at 0:57 Saturday 15th April, 2006
|
|
|
|
|
2hdass wrote: Recently i created my own web control. I want to make it so that i will recieve arguments like
<.uc1:treeFrame ID="TreeFrame1" runat= "server" argument1= "blah1" argument2= "blah2"/>
You'll want to define "argument1" and "argument2" as properties in your user control. Read the MSDN article An Extensive Examination of User Controls[^] by Scott Mitchell for a better understanding and an example.
2hdass wrote: when i add my own user control to a html page by dragging it onto the designer, it puts this at the top of the html
<%@ Register Src="treeFrame.ascx" TagName="treeFrame" TagPrefix="uc1" %>
The designer is simply registering the custom control on the page so it may be referenced in the markup. Look at the MSDN documentation for the @Register Page declaration[^] for a fuller description.
|
|
|
|
|
Has anyone ever created reports dyanmically? We have been looking into sql reporting services but have found that the report layout must be previously defined. We would like a user to choose data through a web interface and then autmatically generate a report using .net. Anyone have any ideas on how this could be done?
|
|
|
|
|
hi,
You want crystal report ????
if u want i have a solution according to your requirment.
jitendra
|
|
|
|
|
Hi,
Ive got several DataLists on a page. Im using a method to fill the DataSet and Bind the data to each datagrid in turn. So im effectively re-using the same data set to get data from the same adapter and from the same table.
The only difference is that each DataList is to be populated based on different queries eg retreiving orders based on their category - food, drink, desserts etc.
The problem is, each time i fill the dataset it just adds the new content to the old, and thus each DataList displays the info obtained from the previous query strings.
Is there anyway to avoid this, or perhaps to flush the DataSet after i fill each DataList?
Thanks
munklefish
|
|
|
|
|
Hi Munklefish
We're gonna have to see some code to determine where it goes wrong.
It sounds more like the data is being added to the lists on top of what is already there.. but as I said - post some code and we'll catch that bug
The code you're looking for to empty a datatable is:
dtMyDataTable.Clear();
More specifically - let's see where you
- fill the datasets/datatables
- add data to the lists
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
-- modified at 16:56 Friday 14th April, 2006
|
|
|
|
|
Ok, Heres how i call method on Page_Load
loadDDL("tapas");<br />
loadDDL("paellas");<br />
loadDDL("postres");<br />
loadDDL("desserts");<br />
loadDDL("bebidas");<br />
loadDDL("vinos");
And here is the contents of the method:
private void loadDDL(string input)<br />
{<br />
string checksql="SELECT * FROM tbl_Orders WHERE orderTableID = '"+tmpTable+"' AND orderUserID = '"+tmpCustLast+"' AND orderCategory = '"+input+"' AND (OrderTime BETWEEN '"+preDate+"' AND '"+dateNow+"') ORDER BY orderTime DESC, orderUpdated DESC";<br />
myAdapter.SelectCommand.CommandText=checksql;<br />
myAdapter.Fill(dataSet11, "tbl_orders");<br />
switch(input)<br />
{<br />
case "tapas":<br />
{<br />
DataList1.DataSource= dataSet11;<br />
DataList1.DataBind();<br />
break;<br />
}<br />
case "paellas":<br />
{<br />
DataList2.DataSource= dataSet11;<br />
DataList2.DataBind();<br />
break;<br />
}<br />
case "postres":<br />
{<br />
DataList3.DataSource= dataSet11;<br />
DataList3.DataBind();<br />
break;<br />
}<br />
case "desserts":<br />
{<br />
DataList4.DataSource= dataSet11;<br />
DataList4.DataBind();<br />
break;<br />
}<br />
case "bebidas":<br />
{<br />
DataList5.DataSource= dataSet11;<br />
DataList5.DataBind();<br />
break;<br />
}<br />
case "vinos":<br />
{<br />
DataList6.DataSource= dataSet11;<br />
DataList6.DataBind();<br />
break;<br />
}<br />
<br />
<br />
}<br />
<br />
}
Rather than the new results overwritting the old in the DataSet, they are being added to it.
P.s Jakob,
Jakob Lund Krarup wrote: 10 kinds of people in the world:
- Those who understand binary
- Those who don't
I saw one of your posts ages ago and thought id add the binary joke as my footer in response to yours! I see you've adopted it now.
|
|
|
|
|
Hi Munklefish
You're right you need to add a line of code to your fill part.
Change :
munklefish wrote: myAdapter.SelectCommand.CommandText=checksql;
myAdapter.Fill(dataSet11, "tbl_orders");
To:
myAdapter.SelectCommand.CommandText=checksql;
dataSet11.Clear();
myAdapter.Fill(dataSet11, "tbl_orders");
That should do the trick.
munklefish wrote: P.s Jakob,
Jakob Lund Krarup wrote:
10 kinds of people in the world:
- Those who understand binary
- Those who don't
I saw one of your posts ages ago and thought id add the binary joke as my footer in response to yours! I see you've adopted it now.
hehe .. yup - I have it on a T-shirt, and your footer reminded me that it was the perfect companion to my own footer
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Jakob Lund Krarup wrote: dataSet11.Clear();
Jakob,
How come this command has evaded me? Ive looked everywhere for something logical like this but have found no references! Even VS.Net doesnt give me any suitable response.
So much trouble for such a simple solution!!!
Thanks for the help!!!!
munklefish
|
|
|
|
|
Hi Munklefish
I know the feeling. It happens to us all.
There is also a Clear() method on the DataTable class, if you only want to clear a table, and not all tables in a DataSet.
You might consider storing the different tables in one dataset, and then storing the DataSet in Application, to make it easier on the database?
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Jakob Lund Krarup wrote: You might consider storing the different tables in one dataset, and then storing the DataSet in Application, to make it easier on the database?
Jakob,
What does this involve, and how do i do it? I'm totally in this dark on this method.
Thanks!
Munklefish
|
|
|
|
|
Hi Munklefish
Well, now that I've looked your code over again, it seems that you fill the DataTable with very different data for each request, based on the search being done. The method I was referring to is most useful if you have a couple of tables that very seldomly change, then you can load those into Applicationstate (a piece of RAM on the webserver that is shared between all users).
It would work something along the lines of (coding from memory here - might need a bit of IntelliSense later ):
protected void LoadData()
{
if(Application["myData"] == null)
{
dsMyData = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM orders", strConnectionString);
adapter.Fill(sdMyData, "orders");
Application["myData"] = dsMyData;
}
else
dsMyData = (DataSet)Application["myData"];
}
This requires your connectionstring to be in the variable strConnectionString and a DataSet named csMyData to be declared on the Page level. Then you can call the LoadData method from the PageLoad eventhandler, and you will always have the tables in RAM, except for the first time of course. Application is emptied when the last users Session times out (by default 20 minutes after his/her last click on the page).
Since you actually don't need the DataTables in the code you showed me, then the DataReader is actually faster for just getting stuff from the DataBase. (also from memory ... don't hit me if it's not perfect!)
SqlConnection connection = new SqlConnection("server=(local);database=shop;user=me;password=secret");
SqlCommand command = connection.CreateCommand();
command.CommandText = "SELECT * FROM orders WHERE ...yadayadayada...";
connection.Open();
dlOrders.DataSource = command.ExecuteReader();
dlOrders.DataBind();
connection.Close();
Hope this was of some use to you.
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Jakob,
Very Interesting. Ill take a look at that when i have some time.
At the moment im struggling with some other stuff. (see my latest pst)
Thanks again!
Happy Easter!
|
|
|
|
|
munklefish wrote: Happy Easter!
you too
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Jakob Lund Krarup wrote: hehe .. yup - I have it on a T-shirt.......
GEEK!
|
|
|
|
|
Hehe... - yup! (and proud of it - schhh )
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
After I covert a 2005 Web Site Project to a 2005 Web Application Project, I got the following Error on a web reference which point to a web service. I removed the reference and add it again but got the same error:
Custom tool error: Unable to import WebService/Schema. Exception of type 'System.Exception' was thrown.
Any help is appreciated.
|
|
|
|
|
Having a huge problem using different IIS servers and one SQL Server State. When the user goes from computer A to B the B computer quicks him out to Login again.
Any solution?
Cheers
Al
My eMail control
My Blog
|
|
|
|
|
|
Thanks, that's what I did. Actually you need to compile a program to generate the machinekey. Just thought that could be added into the Service State to be better solution!
I am writing my own Session State, will see how it comes out
Thanks for all your help!
Al
My eMail control
My Blog
|
|
|
|