|
Hi,
I am struggling to add a dataset to the database. So this is what happens. I fill a dataset with data from a database table. Then I want to use that info in some functionality I need to do. Here the client can use some of that data in the dataset, and once he is done, I want to submit that dataset back to the database, but a different table.
My problem is, how do I add a dataset with about 500 - 600 rows to the database at once. One reason why I want to use this method is, is that I only have to do the select and insert statement once.
Any other ideas also welcome.
|
|
|
|
|
Save the dataset xml string and store that string in the database table field, then retrive it and again create the dataset, you can use readxml and write xml methods of dataset for this.
Ram
|
|
|
|
|
Ramasubramaniam wrote: Save the dataset xml string and store that string in the database table field
Ever heard about relational databases?
only two letters away from being an asset
|
|
|
|
|
Set the InsertCommand and UpdateCommand to store your records in the appropriate table then call Update on the DataAdapter.Update
only two letters away from being an asset
|
|
|
|
|
Here is my dilima. I am kind of new to programming in asp.net, so bear with me. I am building a simple insertion script in asp.net and I am a little confused on how to properly carry out this coding.
I have a MS SQL Database
I have two tables
tblAccount
tblDirectory
In the tblAccount, the "accountID" is the primary key
It is also a foreign key in the tblDirectory
I want to be able to create accounts in the tblAccount table. In the asp.net application, I want the user to be able to login using the information they registered in the account table, and then enter data in the tblDirectory table and that information still be attached to the "accountID" field in the tblAccount table.
This is for a simple directory application. In otherwords, I register for an account, and then I can login and see the details of my account. I have two businesses that I want to enter into the database. So I want to be able to come in, enter my first business and when that is loaded, I can come back and enter my second business.
I think this is a one-to-many relationship in the database. Is there a tutorial on how to accomplish this using asp.net? I want to make sure that when the person logs in, only their information comes up and they can enter their businesses in the tblDirectory database.
Thanks in advance for your help.
The Black Lotus
|
|
|
|
|
Another question, if I create an account in the tblAccount table, will it automatically create an entry in the tblDirectory table, just with all of the other fields empty with the acception of the matching accountID table?
|
|
|
|
|
No, in SQL zero is many too :p
|
|
|
|
|
|
I usually create a structure of the details item.
Here is an example of code that I use create a header record and then detail items.
<br />
<br />
<br />
<br />
public void UpdateMonoLinePropMaxLimits(int RateGroupCode, DateTime EffectiveDate, MonoLineMaxLimit[] LimitsRows)<br />
{<br />
SqlConnection conn = UAIG.SQL.ConnectionManager.GetConnection();<br />
SqlCommand cmd1 = new SqlCommand();<br />
cmd1.CommandText = "dbo.uspUpdatePropMaxLimit";<br />
cmd1.Connection = conn;<br />
cmd1.CommandType = CommandType.StoredProcedure;<br />
cmd1.Parameters.Add(new SqlParameter("@RateGroupCode", RateGroupCode));<br />
cmd1.Parameters.Add(new SqlParameter("@EffectiveDate", EffectiveDate));<br />
cmd1.Parameters.Add(new SqlParameter("@NetID", UAIG.Settings.ApplicationSettings.GetUser()));<br />
SqlParameter prmReturnValue = new SqlParameter("@ReturnValue", SqlDbType.Int);<br />
prmReturnValue.Direction = ParameterDirection.ReturnValue;<br />
cmd1.Parameters.Add(prmReturnValue);<br />
conn.Open();<br />
SqlTransaction trans = conn.BeginTransaction();<br />
cmd1.Transaction = trans;<br />
cmd1.ExecuteNonQuery();<br />
<br />
<br />
int MaxLimitGroup = int.Parse(prmReturnValue.Value.ToString());<br />
SqlCommand cmd2 = new SqlCommand();<br />
cmd2.CommandType = CommandType.StoredProcedure;<br />
cmd2.Connection = conn;<br />
cmd2.CommandText = "dbo.uspInsertMaxLimit";<br />
cmd2.Parameters.Add(new SqlParameter("@MaxLimitGroup", MaxLimitGroup));<br />
SqlParameter prmConstructionTypeCode = new SqlParameter("@ConstructionTypeCode", SqlDbType.Int);<br />
cmd2.Parameters.Add(prmConstructionTypeCode);<br />
SqlParameter prmSprinklered1_6 = new SqlParameter("@Sprinklered1_6", SqlDbType.Money);<br />
cmd2.Parameters.Add(prmSprinklered1_6);<br />
SqlParameter prmSprinklered7_8 = new SqlParameter("@Sprinklered7_8", SqlDbType.Money);<br />
cmd2.Parameters.Add(prmSprinklered7_8);<br />
SqlParameter prmNonSprinklered1_6 = new SqlParameter("@NonSprinklered1_6", SqlDbType.Money);<br />
cmd2.Parameters.Add(prmNonSprinklered1_6);<br />
SqlParameter prmNonSprinklered7_8 = new SqlParameter("@NonSprinklered7_8", SqlDbType.Money);<br />
cmd2.Parameters.Add(prmNonSprinklered7_8);<br />
<br />
foreach (MonoLineMaxLimit item in LimitsRows)<br />
{<br />
prmConstructionTypeCode.Value = item.ConstructionTypeCode;<br />
prmSprinklered1_6.Value = item.Sprinklered1_6;<br />
prmSprinklered7_8.Value = item.Sprinklered7_8;<br />
prmNonSprinklered1_6.Value = item.NonSprinklered1_6;<br />
prmNonSprinklered7_8.Value = item.NonSprinklered7_8;<br />
<br />
cmd2.Transaction = trans;<br />
cmd2.ExecuteNonQuery();<br />
<br />
}<br />
<br />
trans.Commit();<br />
conn.Dispose();<br />
}<br />
<br />
public struct MonoLineMaxLimit<br />
{<br />
public int ConstructionTypeCode;<br />
public decimal Sprinklered1_6;<br />
public decimal Sprinklered7_8;<br />
public decimal NonSprinklered1_6;<br />
public decimal NonSprinklered7_8;<br />
}<br />
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
So you can have two different insert commands for the same form?
|
|
|
|
|
hi everybody i want know how to add webparts nd webpartszone at runtime,
see the site www.netvibes.com
i wnt to add web parts same like thatt
reply me quic thank you
intresting in asp.net
|
|
|
|
|
For a while now, I've simply used panels, and made them visible=true/false to change the view.
However I started playing with the multi view and it seems to have them same functionality and well only one seems to be able to be active at a time.
When I was reading about a multi view and read that it loads all controls reguardless of active view. (maybe I misunderstood this part)
In my current setup I have:
If i have a multi view with three views, or a page with 3 panels.
The views would have a gridview, listview, and a details view, and same with the panels.
Now due to the nature of these views, I have been using 3 different object sources, one for each.
So now comes my question:
If I do a multi view, does that mean that every time the page is reloaded, that it will requery the DBF for each of the views? since they are all in existance? (thus, 3 database queries per page load?)
What about if a panel that contains a gridview that is not visible. I think that the object is not even sent to the client, and I'd assume that it would not even be created, and thus no object query made. Is that a safe assumption?
Lastly, does anyone know a good way to track/count database queries made every time a page is loaded? Maybe a code snip or a log file that could be checked?
Drathmar
|
|
|
|
|
Drathmar wrote: If I do a multi view, does that mean that every time the page is reloaded, that it will requery the DBF for each of the views? since they are all in existance? (thus, 3 database queries per page load?)
Only the active view makes a request to DB, and it's not for all time, basically the control in the active view is filled with data from DB for the first time it displays, and for the next postbacks it is normally recreated from the ViewState instead of DB..
Drathmar wrote: What about if a panel that contains a gridview that is not visible. I think that the object is not even sent to the client, and I'd assume that it would not even be created, and thus no object query made. Is that a safe assumption?
The object does get created regardless of its visibility, but normally the control with the Visible=false does not bind data, it means it does not make a request to DB. However, if the Visible is set too late in the control life cycle, it still executes the Db query, but does not render.
Drathmar wrote: Lastly, does anyone know a good way to track/count database queries made every time a page is loaded? Maybe a code snip or a log file that could be checked?
The simple way is to use the SQL Profiler to profile the current DB to see any queries sent to the database when the page is loaded. In addition, you can use your code or any library out there like log4net to log any calls that are made to your data access code.
|
|
|
|
|
I'm a long-time developer new to C# and ASP.NET. One of the first sites I'm working on will be a collection of documents, which would grow from visitor contributions. I would like this to work much like it does at The Code Project.
I'm trying to figure out the best way to do this. I could simply store the documents as Web pages. Or I could store the documents as Web pages and simply index them in a database. Or I could actually store the documents in the database and dish them out as requested, I assume with some sort of cache to improve performance.
I know The Code Project uses a combination of a database and Web pages but I don't know exactly how. Can anyone offer some pros and cons of these different approaches. Please include as much detail as you'd care to as I'm pretty new to Web development.
Thanks
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
|
|
|
|
|
Hello,
In ASP.NET 2.0 application while using Forms Authentication, if user sees Login page due to session timout, is there anyway I can find out at login page that user came to this page because of session timeout and can show some message to user that he/she is redirected to this page because of Session timeout.
Appreciate any help in this regard.
- ashish
|
|
|
|
|
Hi there. One of the ways you can do is to use the Session Start event, and in the handler you can check if the authentication cookie is existing or not. If not, this is a new user, otherwise the existing user is kicked out due to the session time out.
|
|
|
|
|
I am binding dropdown with database using datasource.
I don't have any --Select-- option in the database.
Now i wan't to bind the --select-- option as the first element of dropdown so that the Index of --select- option is 0
This all the Bind was doing dynamically
Kindly help me
Madhu
|
|
|
|
|
After you have bound the datasource to the dropdown insert an item to it
ddl.Items.Insert(0, "--Select--");
only two letters away from being an asset
|
|
|
|
|
Hi,
you can use following query instead
SELECT 0, '--Select--'
FROM Products
union
select productid,productname from products
just replace ur table names.
hope this works.
Nitin...
|
|
|
|
|
Hi all,
I am using Repeater Control in asp.net 2.0. In this, i ve dynamically created the Repeater Templates ( Header, Item, Footer, etc..) , following the MSDN URL and it works fine.
http://msdn2.microsoft.com/en-us/library/0e39s2ck.aspx[^]
My Objective:
I wish to Construct each Template in different Class, NOT in the same class (Codebehind class) where i ve used my Repeater control in the Page (.aspx file).
In this , how can i implement the Item_DataBinding event handler ?
I need the logic in which it can be implemented ? Pls. Help me ?
-- modified at 9:46 Friday 25th August, 2006
Regards,
Jay
|
|
|
|
|
Hi, if I understand correctly.
You want to use a function from a different class, to implement Item_databinding.
You can maybe have a look at the Objectdatasource. The ODS can be used as a way to call a method from another class... here is a simple example (I used a gridview in this example).
<asp:ObjectDataSource id="odsInvoice" TypeName="Mynamespace.Business.Invoices"<br />
SelectMethod="GetDetails" runat="server"><br />
</asp:ObjectDataSource><br />
<br />
<asp:gridview id="gvInvoices" runat="server" datasourceid="odsInvoice" <br />
autogeneratecolumns="true" Width="980" AllowSorting="False" />
Here I use a ODS to fill my gridview from another class that contains the method.
|
|
|
|
|
Thanks for your reply. But this is not, what i am expecting. I think, my question is not clear.
I wish to create the Repeater Control's Templates Dynamically using C# Class.
For that, u am using a class,
public class MyTemplates : System.Web.UI.ITemplate
{
public MyTemplates(template_type){ }
//Other code here.
}
This Class is Present in the Code Behind (.cs) of the Web (.aspx) Page.
Also this Template Class (mentioned above) is Present Inside of a Class which Inherits Page Class. I ve given the outline below.
public partial class ExampleClass: System.Web.UI.Page
{
Page_Load(object sender, EventArgs e) { }
static void Item_DataBinding(object sender, System.EventArgs e) { }
public class MyTemplates : System.Web.UI.ITemplate { }
}
This "Item_DataBinding" event handler is used by MyTemplates Class, Ok. But, this event handler is belongs to Page Class.
In this, if i take out the "MyTemplates" class and Put it as a seperate class, how can i make use of the "Item_DataBinding" event handler?. This is my doubt?
My AIM is to Create Dynamic Templates outside ( C# Class), and use that Template in my Web Page Code Behind class , and bind the values of the Controls in the Page using "Item_DataBinding" event handlder.
Any Suggestions ?
Regards,
Jay
|
|
|
|
|
In the C file I have this function
DllExport int FunctionName(char *oStrP, const char *iStrP){<br />
}<br />
I did this to import it:
[DllImport(@"path\Mydll.dll", EntryPoint="FunctionName", SetLastError=true, CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)]<br />
unsafe public static extern int FunctionName(ref char * oStrP, ref char [] iStrP);
but I'm getting errors when actually calling the function.
I've tried string, char[], char*, but it always fails.
What should be the correct syntax for this?
tnx !!
I've found a living worth working for, but I haven't found work worth living for.
<marquee>
|
|
|
|
|
|
|