Does Anybody Know Where I Can Learn How To Add, Update, Delete Using SQL Datasource Control?

Mar 24, 2008

does anybody know where I can learn how to add, update, delete using SQL datasource control?  I have a couple of books that shows me how to SELECT but nothing shows me how to update, add new record or delete with the SQL data source control. Even this website doesn't have any tutorial. Does any body know where I can read up on how to use all features of this control? Or where that have a couple of examples on how to use it? 

View 5 Replies


ADVERTISEMENT

SqlDataSource Insert, Update Delete Options Are Dimmed In Configure DataSource Control

Mar 23, 2008

I can select the tables and fields, but when I click on Advanced the Check Box to Create the Commands is not available. they are dimmed out.
Why is this happening, is it a setting that I have missed. Any help is appreciated.

View 1 Replies View Related

Datasource Won't Update On Delete

Jul 12, 2004

hi,

I have a dataadaptor which i use to fill a dataset. I can do this no problems. But if I delete a row from the dataset and update the adaptor again, nothing gets changed in my source database. Does anyone know why this is?

here's my code for my dataadaptor:
SqlConnection conn = new SqlConnection(connectionString);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand("select * from tblExtRef", conn);
adapter.SelectCommand.Connection = conn;

SqlParameter parm;
SqlCommand cmd;
cmd = new SqlCommand("DELETE FROM tblextref WHERE extrefid = @extrefid",conn);
parm = cmd.Parameters.Add("@extrefid", SqlDbType.Int , 40, "extrefid");
parm.SourceColumn = "ExtRefid";
//parm.SourceVersion = DataRowVersion.Original;
//parm.Direction = ParameterDirection.InputOutput;
//SourceVersion = DataRowVersion.Original;
adapter.DeleteCommand = cmd;

View 1 Replies View Related

Insert Works, But Delete And Update Don't In A DetailsView Control

Mar 28, 2008

I have 2 Gridviews and a DetailsView for each GridView. The first Gridview and DetailsView work fine and I can Insert, Delete and Update the DetailsView just fine.  However the second Gridview/DetailsView will only let me Insert but not Delete or Update.  When I click on the "Delete" button it just ignores me.  If I do an "Edit", when I try to click on the "Update" button it is ignored again and I have to click on "Cancel".  I don't get any error messages...
 
Anyone have an idea what might be wrong?

View 4 Replies View Related

SQL Data Source Control...Generate Insert, Update && Delete Statements...

Apr 23, 2008

I have an SQL data source on my page and I select "Table".  On the next screen I pick the fields I want to show.  Then I click the "Advanced" button because I want to allow Inserts, updates and deletes.  But its all greyed out abd I can't check this option. The UID in the connection string I am connecting under has the correct permissions in SQL server to do inserts, update and deletes too.  Anyone know why it would be greyed out? The connectionstring property in the aspx code is dynamic but this shouldn't be the reason because I have used this before with success

View 2 Replies View Related

Can't Access The Datasource Control

May 21, 2006

When I put a sqldatasource in my page and want to configure it and add a new connection to it I recieve this error : "object reference not set to an instance of an object" . Do you have any idea about solving this problem. please help me Thanks

View 5 Replies View Related

Help Assigning A Datasource To The Gmap Control In C#

Sep 18, 2007

I'm trying to assign a datasource to a gmap control in 2.0 so that i can get pushpins in the map for all the locations in the sql db. I've enclosed my code below as well as a link to the site that provides the control and their sample. Can anyone tell me why it won't show the pins? What am I doing wrong?
Thanks.
 My Code (sqllocations is a datasource):
GMap1.DataSource = sqllocations;
GMap1.DataBind();
Their site: http://en.googlemaps.subgurim.net/ejemplos/ejemplo_991000_DataSource.aspx
Their example (part of their explanation is not english, sorry):
 List<DataSourceField> fields = new List<DataSourceField>(); fields.Add(new DataSourceField(45, 2, "hola"));fields.Add(new DataSourceField(46, 3));// Lo comentamos porque al utilizar la clase DataSourceField, // pero si fuera un dataset o cualquier otra cosa, // le deberíamos dar los nombres correspondientes// GMap1.DataLatField = "lat";// GMap1.DataLngField = "lng";// GMap1.DataGInfoWindowTextField = "gInfoWindowText";GMap1.DataSource = fields;GMap1.DataBind();  
 

View 1 Replies View Related

Error Trapping Of Datasource Control

Oct 1, 2007

Hello,
I encountered an interesting situation. I have a gridview and a sqldatasource. It has delete function. When I delete a record an error of foreign key violation is raised. I would like to trap this error and give a user friendly message to the user.
If I use ADO.Net I can use Try/Catch, but it seems there is no way to do the same thing using datasource. Anyone knows?
Thank you,
J

View 6 Replies View Related

Dirty Read With DataSource Control

Nov 19, 2007

Hi all,
Can anyone tell me how I can do a "Dirty Read" on a SqlDataSource Control? I'm affraid that the record locks are causing problems on the live system.
It is connected to an infromix db using odbc. Thanks. 

View 1 Replies View Related

How To Check DataSource Control For Values

Jan 18, 2008

Hey all,
 I was wondering what the best method of checking on page_load if a datasource control is pulling back nothing from a database.  I want to display a message explaining that there is no data to be displayed.  How would I go about doing that?  I have tried searching google and whatnot but didn't find anything really helpful.
Here is the current code for the data source control.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|EventInsider.mdf;Integrated Security=True;User Instance=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT Events_Groups.GroupName, Events_Groups.GroupID FROM Events_GroupMembership INNER JOIN Events_Groups ON Events_GroupMembership.GroupID = Events_Groups.GroupID WHERE (Events_GroupMembership.UserID = @UserID)">
<SelectParameters>
<asp:SessionParameter Name="UserID" SessionField="UserID" />
</SelectParameters>
</asp:SqlDataSource>
 But I have no idea what the code behind would be to check it on page_load.  If there is no way to particularly do this, do you have to do it per control?  Like dropdownbox's or gridviews?  I am just confused on how to check to make sure there is data to be displayed.
Thanks,
Chris

View 3 Replies View Related

How Come I Can Connect To A Database Through A Datasource Control, But Not Code?

Apr 11, 2006

Hi I am trying to open a database connection to a Northwind database.  I can open it with a datasource control and return data to a gridview, but can't programically.  I get a sqlexception error.  this is ust for learning.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim S As New SqlConnection        Dim builder As New SqlConnectionStringBuilder        builder("Data Source") = ".SQLEXPRESS;AttachDbFilename=C:SQLNORTHWND.MDF"        builder("Integrated Security") = True        builder("Connect Timeout") = 30        builder("User Instance") = True        S.ConnectionString = builder.ConnectionString        Me.Label1.Text = S.ConnectionString        S.Open()        Me.Label2.Text = S.State.ToString        S.Close()        Me.Label3.Text = Me.SqlDataSource1.ConnectionString.ToString    End Sub
 The text in label2 and Label three are identical except there are "" around the datasource.
How come I can connect through the datasource control but not through code?

View 6 Replies View Related

SQL 2012 :: Delete Encrypted Key In SSRS But Now Report Cannot Connect To Datasource

Dec 10, 2014

I decided to delete the encryption key.After that when I go to the reporting page, the report cannot connect to the datasource.

An error has occurred during report processing. (rsProcessingAborted)

Cannot create a connection to data source 'xxxxx'. (rsErrorOpeningConnection)

For more information about this error navigate to the report server on the local server machine, or enable remote errors

What do I suppose to do?

View 0 Replies View Related

Delete Extra Rows In Excel Export Thru Report Viewer Control

Jan 28, 2008



Hi,
i hv made a rdl having 2 tables.My requirement is to display the tables on different sheets of excel, so i hv inserted "Page Break At End" in table1.
As a result im getting tables in different sheets but second table (in sheet2) is starting from 2nd row of the sheet i.e. 1st row is coming as hidden, and i want to remove this row as client feed's this excel file in some other application.
If anyone is aware of the solution pl. reply ASAP.

Thank u.

View 3 Replies View Related

Batch Script To Create ODBC And Update Registry Datasource Key - Help!

Feb 21, 2008



I have create a batch file, that creates an ODBC then updates the application datasource key in the registry to the new system dsn name.

The problem is that the new DSN doesn't work when i try and connect the application...but if i had manually created the odbc source the app connects as expected... i have checked the registry and there is no difference between the two dsns created...but the application throws IM002[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified after i have also changed the applications registry key to point to the new database.

Now the interesting things to note are that when i re-create the odbc to the old server and database (sql 2000) by batch file it works fine. The new ODBC is linking to a sql 2005 database, but it is still using the 2000 drivers and when i manually created it, it worked also.

Another interesting thing is that if i go into the odbc dsn and click configure, go through and test the connection it works fine... after i close this i then retry the application and it opens correctly...

I need this to be automated with no manual intervention, as this will be added to a large group of users login scripts!

Any help greatly appreciated.

My batch file code is as below:

ODBCCONF.exe CONFIGSYSDSN "SQL Server" "DSN=RMS Live 2005 | SERVER=d-db99sql2005| Trusted_Connection=Yes | Database=RMS-Livedb"

View 4 Replies View Related

How Can You View The Connection String Of An Existing Datasource? How Do You Delete Existing Dataset?

Nov 14, 2007

I went to look at the connection string previously entered for a dataset created in a new report, and am not seeing anything intuitive for bringing up the associated datasource dialog box that was used to enter name, type and connection string. I'm also noticing nothing intuitive for deleting an existing dataset. How do you do these two very simple things in an existing project? I dont see the dataset in solution explorer, I see it only in the text box on the data tab and in a limited kind of way on the dataset view where the columns show and maint is allowed mostly on the columns only. I tried hilighting the dataset here and hitting the delete key to no avail.

View 1 Replies View Related

Need Help Trying To Work With Forms Control To Update, Insert, And Etc...

Aug 14, 2007

Hello,
I am trying to use the forms view control to do a simple web app. My issue is, I cant get the connection to automatically generate insert, update and delete statements. I tried to do this manually but I always get an error. I have read that I need all the keys selected--this still didnt work.  I have about 6 tables picked in my view, and if I pick one of them then this advanced feature works. I have the primary keys selected.
 here is my saved view. this is in SQL 2000.
SELECT     TOP 100 PERCENT dbo.ADDRESS.EMAIL, dbo.ADDRESS.FIRST_NAME AS [first name], dbo.ADDRESS.LAST_NAME AS [last name],                       dbo.ADDRESS.STATE, dbo.ADDRESS.TEL1 AS phone, dbo.INVOICES.QUOTE_NO AS [SALES QUOTE], dbo.CUST.NAME AS Company,                       dbo.ITEMS.ITEMNO AS [Course Number], dbo.ITEMS.DESCRIPT AS S_Descript, dbo.ADDRESS.JOB_TITLE AS [Job Title],                       dbo.TRAINING_SCHEDULE.[MONTH], dbo.TRAINING_SCHEDULE.S_DATE, dbo.TRAINING_SCHEDULE.END_DATE,                       dbo.TRAINING_SCHEDULE.IS_CONFIRMED, dbo.TRAINING_SCHEDULE.IS_PAID, dbo.TRAINING_SCHEDULE.CUST_CODE AS Account,                       dbo.TRAINING_SCHEDULE.SCHEDULE_ID, dbo.CUST.CUST_CODE, dbo.INVOICES.INVOICES_ID, dbo.X_INVOIC.X_INVOICE_ID,                       dbo.ADDRESS.ADDR_CODEFROM         dbo.TRAINING_SCHEDULE INNER JOIN                      dbo.CUST ON dbo.TRAINING_SCHEDULE.CUST_CODE = dbo.CUST.CUST_CODE RIGHT OUTER JOIN                      dbo.X_INVOIC RIGHT OUTER JOIN                      dbo.INVOICES ON dbo.X_INVOIC.ORDER_NO = dbo.INVOICES.DOC_NO LEFT OUTER JOIN                      dbo.ADDRESS ON dbo.INVOICES.CUST_CODE = dbo.ADDRESS.CUST_CODE LEFT OUTER JOIN                      dbo.ITEMS ON dbo.ITEMS.ITEMNO = dbo.X_INVOIC.ITEM_CODE ON dbo.CUST.CUST_CODE = dbo.ADDRESS.CUST_CODEWHERE     (dbo.X_INVOIC.ITEM_CODE LIKE 'FOT-%') AND (dbo.X_INVOIC.STATUS = 7) AND (dbo.ADDRESS.TYPE IN (4, 5, 6)) AND (dbo.ADDRESS.EMAIL <> '') AND                       (dbo.ADDRESS.COUNTRY = 'UNITED STATES') AND (dbo.ITEMS.CATEGORY = 'TRAININGCLASSES') AND                       (dbo.TRAINING_SCHEDULE.CUST_CODE = 'joe')ORDER BY dbo.ADDRESS.STATE
I am new to this so I am not sure what to include.
thanks,
yellier

View 1 Replies View Related

UPDATE Statement Syntax Help Required C# && SqlDataSource Control

May 3, 2007

Hi,
I need to UPDATE the IP Address of a newly created user into a table (the value is currently set to default - " Not Available"), and I really dont know the syntax required to do this. So far I've derived all the variables needed using the following code:
protected void ContinueButton_Click(object sender, EventArgs e)
{
//Get the ip address and put it into the customer table - (the instance of this user now exists)
MembershipUser _membershipUser = Membership.GetUser();
Guid UserId = (Guid)_membershipUser.ProviderUserKey;<--------------------------------------------------------------I can see the UserId here if I pause the prog
SqlDataSource customerDataSource = new SqlDataSource();
customerDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
customerDataSource.UpdateParameters.Add("IPAddress", Request.UserHostAddress.ToString());<---------------------------------------I can see the IPAddress here
customerDataSource.UpdateCommandType = SqlDataSourceCommandType.Text;
 what next
I've not got a clue as to what to write next. There is a try / catch statement after this using :
rowsAffected = customerDataSource.Update();
which remains at 0 no matter what I try.
Any help greatly appreciated.

View 15 Replies View Related

VB.NET Codebehind Code To Update SQL Server 2005 Using SQLDataSource Control?

Jul 20, 2007

Hi, I am a newbie in using ASP.NET 2.0 and ADO.NET.  I wrote a hangman game and want to record statistics at the end of each game.  I will create and update records in the database for each authenticated user as well as a record for the Anonymous, unauthenticated user.  After a win or loss has occurred, I want to programmatically use the SQLDataSource control to increment the statistics counters for the appropriate record in the database (note I don't want to show anything or get user input for this function).
I need a VB.NET codebehind example that will show me how I should set up the parameters and update the appropriate record in the database.  Below is my code.  What happens now is that the program chugs along happily (no errors), but the database record does not actually get updated.  I have done many searches on this forum and on the general Internet for programmatic examples of an update sequence of code.  If there is a tutorial for this online or a book, I'm happy to check it out.
Any help will be greatly appreciated.
Lambanlaa
CODE - Hangman.aspx.vb
1        Protected Sub UpdateStats()2            Dim playeridString As String3            Dim gamesplayedInteger, gameswonInteger, _4                easygamesplayedInteger, easygameswonInteger, _5                mediumgamesplayedInteger, mediumgameswonInteger, _6                hardgamesplayedInteger, hardgameswonInteger As Int327    8            ' determine whether player is named or anonymous9            If User.Identity.IsAuthenticated Then10               Profile.Item("hangmanplayeridString") = User.Identity.Name11           Else12               Profile.Item("hangmanplayeridString") = "Anonymous"13           End If14   15           playeridString = Profile.Item("hangmanplayeridString")16   17           ' look up record in stats database18           Dim hangmanstatsDataView As System.Data.DataView = CType(statsSqlDataSource.Select(DataSourceSelectArguments.Empty), System.Data.DataView)19   20           gamesplayedInteger = 021           gameswonInteger = 022           easygamesplayedInteger = 023           easygameswonInteger = 024           mediumgamesplayedInteger = 025           mediumgameswonInteger = 026           hardgamesplayedInteger = 027           hardgameswonInteger = 028   29           If hangmanstatsDataView.Table.Rows.Count = 0 Then30   31               '   then create record with 0 values32               statsSqlDataSource.InsertParameters.Clear() ' don't really know what Clear does33               statsSqlDataSource.InsertParameters("playerid").DefaultValue = playeridString34               statsSqlDataSource.InsertParameters("GamesPlayed").DefaultValue = gamesplayedInteger35               statsSqlDataSource.InsertParameters("GamesWon").DefaultValue = gameswonInteger36               statsSqlDataSource.InsertParameters("EasyGamesPlayed").DefaultValue = easygamesplayedInteger37               statsSqlDataSource.InsertParameters("EasyGamesWon").DefaultValue = easygameswonInteger38               statsSqlDataSource.InsertParameters("MediumGamesPlayed").DefaultValue = mediumgamesplayedInteger39               statsSqlDataSource.InsertParameters("MediumGamesWon").DefaultValue = mediumgameswonInteger40               statsSqlDataSource.InsertParameters("HardGamesPlayed").DefaultValue = hardgamesplayedInteger41               statsSqlDataSource.InsertParameters("HardGamesWon").DefaultValue = hardgameswonInteger42   43               statsSqlDataSource.Insert()44           End If45   46           ' reread the record to get current values47           hangmanstatsDataView = CType(statsSqlDataSource.Select(DataSourceSelectArguments.Empty), System.Data.DataView)48           Dim hangmanstatsDataRow As System.Data.DataRow = hangmanstatsDataView.Table.Rows.Item(0)49   50           ' set temp variables to database values51           gamesplayedInteger = hangmanstatsDataRow("GamesPlayed")52           gameswonInteger = hangmanstatsDataRow("GamesWon")53           easygamesplayedInteger = hangmanstatsDataRow("EasyGamesPlayed")54           easygameswonInteger = hangmanstatsDataRow("EasyGamesWon")55           mediumgamesplayedInteger = hangmanstatsDataRow("MediumGamesPlayed")56           mediumgameswonInteger = hangmanstatsDataRow("MediumGamesWon")57           hardgamesplayedInteger = hangmanstatsDataRow("HardGamesPlayed")58           hardgameswonInteger = hangmanstatsDataRow("HardGamesWon")59   60           ' update stats record61           'statsSqlDataSource.UpdateParameters.Clear()62           'statsSqlDataSource.UpdateParameters("playerid").DefaultValue = playeridString63   64           If Profile.Item("hangmanwinorloseString") = "win" Then65   66               statsSqlDataSource.UpdateParameters("GamesPlayed").DefaultValue = gamesplayedInteger + 167               statsSqlDataSource.UpdateParameters("GamesWon").DefaultValue = gameswonInteger + 168               Select Case Profile.Item("hangmandifficultyInteger")69                   Case 170                       statsSqlDataSource.UpdateParameters("EasyGamesPlayed").DefaultValue = easygamesplayedInteger + 171                       statsSqlDataSource.UpdateParameters("EasyGamesWon").DefaultValue = easygameswonInteger + 172                   Case 273                       statsSqlDataSource.UpdateParameters("MediumGamesPlayed").DefaultValue = mediumgamesplayedInteger + 174                       statsSqlDataSource.UpdateParameters("MediumGamesWon").DefaultValue = mediumgameswonInteger + 175                   Case 376                       statsSqlDataSource.UpdateParameters("HardGamesPlayed").DefaultValue = hardgamesplayedInteger + 177                       statsSqlDataSource.UpdateParameters("HardGamesWon").DefaultValue = hardgameswonInteger + 178               End Select79   80   81           ElseIf Profile.Item("hangmanwinorloseString") = "lose" Then82   83               statsSqlDataSource.UpdateParameters("GamesPlayed").DefaultValue = gamesplayedInteger + 184               Select Case Profile.Item("hangmandifficultyInteger")85                   Case 186                       statsSqlDataSource.UpdateParameters("EasyGamesPlayed").DefaultValue = easygamesplayedInteger + 187                   Case 288                       statsSqlDataSource.UpdateParameters("MediumGamesPlayed").DefaultValue = mediumgamesplayedInteger + 189                   Case 390                       statsSqlDataSource.UpdateParameters("HardGamesPlayed").DefaultValue = hardgamesplayedInteger + 191               End Select92           End If93   94           statsSqlDataSource.Update()95   96       End Sub97  
CODE - Hangman.aspx 1 <asp:SqlDataSource ID="statsSqlDataSource" runat="server" ConflictDetection="overwritechanges"
2 ConnectionString="<%$ ConnectionStrings:lambanConnectionString %>" DeleteCommand="DELETE FROM [Hangman_Stats] WHERE [PlayerID] = @original_PlayerID AND [GamesPlayed] = @original_GamesPlayed AND [GamesWon] = @original_GamesWon AND [EasyGamesPlayed] = @original_EasyGamesPlayed AND [EasyGamesWon] = @original_EasyGamesWon AND [MediumGamesPlayed] = @original_MediumGamesPlayed AND [MediumGamesWon] = @original_MediumGamesWon AND [HardGamesPlayed] = @original_HardGamesPlayed AND [HardGamesWon] = @original_HardGamesWon"
3 InsertCommand="INSERT INTO [Hangman_Stats] ([PlayerID], [GamesPlayed], [GamesWon], [EasyGamesPlayed], [EasyGamesWon], [MediumGamesPlayed], [MediumGamesWon], [HardGamesPlayed], [HardGamesWon]) VALUES (@PlayerID, @GamesPlayed, @GamesWon, @EasyGamesPlayed, @EasyGamesWon, @MediumGamesPlayed, @MediumGamesWon, @HardGamesPlayed, @HardGamesWon)"
4 OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT PlayerID, GamesPlayed, GamesWon, EasyGamesPlayed, EasyGamesWon, MediumGamesPlayed, MediumGamesWon, HardGamesPlayed, HardGamesWon FROM Hangman_Stats WHERE (PlayerID = @playerid)"
5 UpdateCommand="UPDATE [Hangman_Stats] SET [GamesPlayed] = @GamesPlayed, [GamesWon] = @GamesWon, [EasyGamesPlayed] = @EasyGamesPlayed, [EasyGamesWon] = @EasyGamesWon, [MediumGamesPlayed] = @MediumGamesPlayed, [MediumGamesWon] = @MediumGamesWon, [HardGamesPlayed] = @HardGamesPlayed, [HardGamesWon] = @HardGamesWon WHERE [PlayerID] = @original_PlayerID AND [GamesPlayed] = @original_GamesPlayed AND [GamesWon] = @original_GamesWon AND [EasyGamesPlayed] = @original_EasyGamesPlayed AND [EasyGamesWon] = @original_EasyGamesWon AND [MediumGamesPlayed] = @original_MediumGamesPlayed AND [MediumGamesWon] = @original_MediumGamesWon AND [HardGamesPlayed] = @original_HardGamesPlayed AND [HardGamesWon] = @original_HardGamesWon">
6 <DeleteParameters>
7 <asp:Parameter Name="original_PlayerID" Type="String" />
8 <asp:Parameter Name="original_GamesPlayed" Type="Int32" />
9 <asp:Parameter Name="original_GamesWon" Type="Int32" />
10 <asp:Parameter Name="original_EasyGamesPlayed" Type="Int32" />
11 <asp:Parameter Name="original_EasyGamesWon" Type="Int32" />
12 <asp:Parameter Name="original_MediumGamesPlayed" Type="Int32" />
13 <asp:Parameter Name="original_MediumGamesWon" Type="Int32" />
14 <asp:Parameter Name="original_HardGamesPlayed" Type="Int32" />
15 <asp:Parameter Name="original_HardGamesWon" Type="Int32" />
16 </DeleteParameters>
17 <UpdateParameters>
18 <asp:Parameter Name="GamesPlayed" Type="Int32" />
19 <asp:Parameter Name="GamesWon" Type="Int32" />
20 <asp:Parameter Name="EasyGamesPlayed" Type="Int32" />
21 <asp:Parameter Name="EasyGamesWon" Type="Int32" />
22 <asp:Parameter Name="MediumGamesPlayed" Type="Int32" />
23 <asp:Parameter Name="MediumGamesWon" Type="Int32" />
24 <asp:Parameter Name="HardGamesPlayed" Type="Int32" />
25 <asp:Parameter Name="HardGamesWon" Type="Int32" />
26 <asp:Parameter Name="original_PlayerID" Type="String" />
27 <asp:Parameter Name="original_GamesPlayed" Type="Int32" />
28 <asp:Parameter Name="original_GamesWon" Type="Int32" />
29 <asp:Parameter Name="original_EasyGamesPlayed" Type="Int32" />
30 <asp:Parameter Name="original_EasyGamesWon" Type="Int32" />
31 <asp:Parameter Name="original_MediumGamesPlayed" Type="Int32" />
32 <asp:Parameter Name="original_MediumGamesWon" Type="Int32" />
33 <asp:Parameter Name="original_HardGamesPlayed" Type="Int32" />
34 <asp:Parameter Name="original_HardGamesWon" Type="Int32" />
35 </UpdateParameters>
36 <InsertParameters>
37 <asp:Parameter Name="PlayerID" Type="String" />
38 <asp:Parameter Name="GamesPlayed" Type="Int32" />
39 <asp:Parameter Name="GamesWon" Type="Int32" />
40 <asp:Parameter Name="EasyGamesPlayed" Type="Int32" />
41 <asp:Parameter Name="EasyGamesWon" Type="Int32" />
42 <asp:Parameter Name="MediumGamesPlayed" Type="Int32" />
43 <asp:Parameter Name="MediumGamesWon" Type="Int32" />
44 <asp:Parameter Name="HardGamesPlayed" Type="Int32" />
45 <asp:Parameter Name="HardGamesWon" Type="Int32" />
46 </InsertParameters>
47 <SelectParameters>
48 <asp:ProfileParameter Name="playerid" PropertyName="hangmanplayeridString" />
49 </SelectParameters>
50 </asp:SqlDataSource>
 

View 2 Replies View Related

Having Trouble Configuring The SqlDataSource Control's Update And Insert Commands

Jul 24, 2007

I've just finished configuring the SELECT command for the SqlDataSource in my ASP.NET 2.0 web app.  It works fine and runs against a SQL Server 2005 database, using a stored procedure that I've written.
So, then I went to configure the SqlDataSource for the UPDATE and INSERT commands, and I've written two SP's for those as well.  In the designer the second form of the wizard asks for the Select statement.  I've already given that for the SELECT statement in the third form, and I also select the INSERT tab to specify the SP I want to use for inserting data and the UPDATE tab to specify the SP I want to use for updating data.  However, there appears to be no way that I can specify what the parameters are supposed to be for anything other than the SELECT command, through the designer.  Is that correct, or have I missed something?
 

View 11 Replies View Related

Issue With Getting Values From Child Controls In A Gridview, To Use For The Update Using A SQLDataSource Control

Nov 21, 2006

Hi all,
I have a gridview bound with a SQLDataSource. I am using the Update feature of the SQLDataSource to update a SQL Server database with values entered into the gridview. However I am not getting it to work. I believe this is due to the controls that contain the user entries are not the gridview itself, but rather child controls within the gridview. I have been using the names of the actual controls but nothing happens. Upon submit, the screen returns blank, and the database is not updated. Here is some code:
 
<asp:GridView ID="GridEditSettlement" runat="server" AutoGenerateColumns="False" BackColor="Navy"
BorderColor="IndianRed" BorderStyle="Solid" Font-Names="Verdana" Font-Size="X-Small" DataSourceID="SqlDataSource_grid" AllowPaging="True" AllowSorting="True" ForeColor="White" DataKeyNames="legid">
<Columns>
<asp:CommandField ShowEditButton="True" CancelImageUrl="~/App_Graphics/quit.gif" CancelText="" EditImageUrl="~/App_Graphics/EditGrid.GIF" EditText="" UpdateImageUrl="~/App_Graphics/save.gif" UpdateText="" ButtonType="Image" />
<asp:BoundField DataField="StartDate" HeaderText="Start Date" ReadOnly="True" />
<asp:BoundField DataField="EndDate" HeaderText="End Date" ReadOnly="True" />
<asp:BoundField DataField="CounterpartDealRef" HeaderText="CP Deal Ref" ReadOnly="True" />
 
<asp:TemplateField HeaderText="Preliminary Settlement Price" ><ItemTemplate>
<asp:Label ID=lblPreliminary runat=server Text='<%# Bind("PrimarySettlementPrice") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID=txtPrimaryPrice Text='<%# Bind("PrimarySettlementPrice") %>'></asp:TextBox>
 
</EditItemTemplate></asp:TemplateField>
 
<asp:TemplateField HeaderText="Agreed Settlement Price"><ItemTemplate>
<asp:Label ID=lblAgreed runat=server Text='<%# Bind("AgreedSettlementPrice") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID=txtAgreedPrice Text='<%# Bind("AgreedSettlementPrice") %>'></asp:TextBox>
 
</EditItemTemplate></asp:TemplateField>
 
 
<asp:BoundField DataField="Volume" HeaderText="Volume" ReadOnly="True" />
<asp:BoundField DataField="Price" HeaderText="Price" ReadOnly="True" />
<asp:BoundField DataField="TotalVolume" HeaderText="Total Volume" ReadOnly="True" />
<asp:BoundField DataField="InstrumentName" HeaderText="Instrument" ReadOnly="True" />
<asp:BoundField DataField="NominalValue" HeaderText="Nominal Value" ReadOnly="True" />
<asp:BoundField DataField="Strike" HeaderText="Strike" ReadOnly="True" />
<asp:BoundField DataField="DeliveryDate" HeaderText="Delivery Date" ReadOnly="True" />
<asp:TemplateField HeaderText="LegId" SortExpression="LegId">
<ItemTemplate>
<asp:Label ID="lblLegID" runat="server" Text='<%# Bind("LegId") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID=txtLegID Text='<%# Bind("LegId") %>'></asp:TextBox>
 
</EditItemTemplate>
</asp:TemplateField>
 
 
</Columns>
<RowStyle BackColor="#FFFF66" ForeColor="#333333" />
<EditRowStyle BackColor="#FFFF66" Font-Names="Verdana" Font-Size="X-Small" ForeColor="#333333" />
<PagerStyle ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#333333" />
</asp:GridView>
&nbsp;<br />
 
<asp:SqlDataSource ID="SqlDataSource_grid" runat="server" ConnectionString="<%$ ConnectionStrings:DealCaptureDev %>" SelectCommand="sp_get_single_deal" SelectCommandType="StoredProcedure" UpdateCommand="Update trDealLeg Set PrimarySettlementPrice=@primarysettlement, AgreedSettlementprice=@agreedsettlement, LastUpdate=GetDate(), LastUpdateBy=Session('userid') Where LegID=@legid" EnableCaching="True" ConflictDetection="CompareAllValues" ProviderName="System.Data.SqlClient">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="" Name="dealnum" QueryStringField="deal"
Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="txtLegId" PropertyName="Text" Name="legId" />
<asp:ControlParameter ControlID="txtPrimarySettlement" Name="primarysettlement" PropertyName="Text" />
<asp:ControlParameter ControlID="txtAgreedSettlement" Name="agreedsettlement" PropertyName="Text"/>
<asp:SessionParameter DefaultValue="" Name="userid" SessionField="userid" />
</UpdateParameters>
</asp:SqlDataSource>
 
As seen above, controls such as txtPrimarySettlement are referenced but the update is not successful. The text boxes are within the GridEditSettlement gridview.  In the .aspx code I cannot use FindControl (at least I don't think it will work).
So the questions are:  Is it possible to reference the child controls, if so - how?  Is there another way to do this, such as in the vb code behind - in the either the gridview's RowUpdating event or the SQLDataSource's Updating event.
What is the best approach?  Anyone come up against this issue before?
 Thanks,
KB

View 1 Replies View Related

Can I Use A SqlDataSource Control Exclusively To Pass Data To A Stored Procedure For Execution (insert/update Only)?

Feb 28, 2008

Hi,
I'm reasonably new to ASP.NET 2.0
I'm in my wizard_FinishButtonClick event, and from here, I want to take data from the form and some session variables and put it into my database via a stored procedure.  I also want the stored procedure to return an output value.  I do not need to perform a select or a delete.
For the life of me, I can't find a single example online or in my reference books that tells me how to accomplish this task using a SqlDataSource control.  I can find lots of examples on sqldatasources that have a select statements (I don't need one) and use insert and update sql statements instead of stored procedures (I use stored procedures).
I desperately need the syntax to:
a) create the SqlDataSource with the appropriate syntax for calling a stored procedure to update and/or insert (again, this design side of VS2005 won't let me configure this datasource without including a select statement...which I don't need).
b) syntax on how to create the parameters that will be sent to the stored procedure for this sqldatasource (including output parameters).
c) syntax on how to set the values for these parameters (again...coming from form controls and session variables)
d) syntax on how to execute, in the code-behind, the stored procedure via the sqldatasource.
If anybody has sample code or a link or two, I would be most appreciative.
Thank you in advance for any help!

View 5 Replies View Related

Delete And Update

Mar 6, 2007

Hi All,I have a Access front-end,the tables are from SQL server 2000 andlinked via ODBC using DSN.I have a Main table and several related tables.The Main table has aOne -to- Many relationship with the related tables.When I try to delete a record from the front-end,I get a error msg "the table is locked,you and another user are attempting to delete/update the same record".I am the single user and I am at a loss tounderstand what the problem is.I have to explain that I never had a problem when i was using Accessas the backend too.Is it because of linking?Any suggestions?Roy

View 2 Replies View Related

Update And Delete

Jul 11, 2006

I need to update rows in database A from data in database B and delete from database B if a match is found but leave in databse B if no match found. Is there a way do do this with the OLe DB command?

View 1 Replies View Related

Cascading Update And Delete

Aug 18, 2007

If we want to maintain the data in relationships.
There are two ways to do it.
1. Auto (Like Cascading Update And Delete)
2. Manually (Like In Stored Procedures)
I read an intresting article
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=419
In this article Imar has choosen the second way (Manually).
And when I talk to Imar.
He said, "Cascading deletes would have worked equally well in this situation. However, I personally don't like them too much. I am much rather in control, enabling me to delete what I want and when I want it. I could, for example, keep certain data for "time travelling scenarios" (e.g. the state things were in some time ago) or I might want to keep it for other purposes."
Can any one help me to choose the better one.
 
Waiting for helpful replies.

View 2 Replies View Related

Update Or Delete With Insert?

Dec 13, 2007

Hi All,
I have this project I'm working on it's Product Content Management System rewrite. I got to the point of updating the Product By Sku and not sure if I should use UPDATE statement or I should DELETE sections assosiated with the ProductContentID and then re-insert them again? I'm not sure which is more afficient?
I can really do both and it's really not that complicated, the only problem I see with DELETE then INSERT is the ProductContentSectionId in the Sections table is going to grow very fast and I'm a bit concerned about it.
We use SQL Server 2000 and we have about 4 bound tables where we keep the data. The one I'm talking about is the sections table where we keep the actual types of product content like a BoxShot, Description, Key Features and so on...
Thank you in advance!
Tatyana Hughes
 

View 3 Replies View Related

Problems With UPDATE And DELETE

Mar 21, 2008

I have two buttons on my page, one which will update content the other which will delete content from my slq database.
I get this error "CS1501: No overload for method 'updateBlockContent' takes '2' arguments" when I click on my update button.
I get this error "CS1501: No overload for method 'deleteBlockContent' takes '2' arguments" when I click on my delete button.
This is my method for updating - UPDATE [CMS] SET [BlockName] = @BlockName, [BlockContent] = @BlockContent WHERE (([BlockID] = @Original_BlockID))
This is my C# code behind the update button:protected void btnUpdateBlock_Click(object sender, EventArgs e)
{CMSTableAdapter ta = new CMSTableAdapter();
try
{
ta.updateBlockContent(txtBlockName.Text, txtBlockContent.Text);lblFeedback.Text = "Block Updated.";txtBlockName.Text = txtBlockContent.Text = "";
}
catch (Exception ex) { lblFeedback.Text = ex.ToString(); }
finally
{lblFeedback.Visible = true;
ta.Dispose();
}
}
This is my method for deleting - DELETE FROM [CMS] WHERE (([BlockID] = @Original_BlockID))
This is my C# code behind the delete button:protected void btnDeleteBlock_Click(object sender, EventArgs e)
{CMSTableAdapter ta = new CMSTableAdapter();
try
{
ta.deleteBlockContent(txtBlockName.Text, txtBlockContent.Text);lblFeedback.Text = "Block Deleted.";txtBlockName.Text = txtBlockContent.Text = "";
}
catch (Exception ex) { lblFeedback.Text = ex.ToString(); }
finally
{lblFeedback.Visible = true;
ta.Dispose();
}
}
Can somebody please explain why this is happening and how to remedy this problem.
Thanks,
Chris.

View 5 Replies View Related

Cascade Delete And Update In SQL 7.0

Jul 23, 1999

Is it possible to cascade update and delete while DRI remains there ? That
is without deleteing refrential integrity. If anyone have example of cascade delete and Update using Pubs or Northwind Example , i'll be really obliged.

View 1 Replies View Related

Update, Delete, Insert

Jan 8, 1999

I am trying to update a SQL database with data from a Wang system. The Wang data is dumped to a txt file. I then import it into an update table in SQL via Access. Some of the data is new and some of the data is updated records. At this point I have been trying to create a script to update and add data to a table via the query tool in SQL Then delete data from the update table.

I was able to get the UPDATE and DELETE to work but I have not figured out how to insert new records at the same time? Can I use an IF statement? I will apreciate any help or sample code, Thanks.

UPDATE MemberList
Set Name = NameUpd, Address1 = Address1Upd, Address2 = Address2Upd, City = CityUpd, State = StateUpd, ZipCode = ZipCodeUpd, MemberStatus = MemberstatusUpd
FROM MemberList, MemberListUpd
WHERE MemberList.MemberNumber = MemberListUpd.MemberNumberUpd

INSERT ?

DELETE MemberListUpd

View 2 Replies View Related

Limiting UPDATE And DELETE

Feb 16, 2007

I know how to do this in MySQL; but I was hoping there was a way to do it in MS SQL.

I want to be able to limit the number of rows an UPDATE or DELETE will effect regardless of the WHERE clause. I want to do this as a stop gap in the event that there is a logical error in the WHERE clause that would make it effect more rows than is humanly intended.

If I write a complex query that I know should drill down to only affecting one row, I just want to lock it in before I run it on database and take the risk of damaging some data.

In MySQL you would just do something like this:

Code:

DELETE FROM table_name WHERE ... LIMIT 1;



The only thing close to LIMIT I could come up with for MS SQL was TOP but it seems to only work for SELECT.

Any ideas would be greatly appreciated.

I ask this because if you screw up; manually saving 1, 2 or even 5 rows is a lot easier than having to rescue a whole table of data (even if it on a development server).

View 2 Replies View Related

Update And Delete Stmt.

May 11, 2007

Hi,
I have two tables:

1. RubricReport
2. RubricReportDetail

How can I code this step in my stored procedure:

If @ReportID is NULL, insert a row into RubricReport table, and set @ReportID=@@IDENTITY; otherwise, update table RubricReport for columns LastUpdate and LastUpdateBy, and delete table RubricReportDetail where ReportID=@ReportID.

Table RubricReport has columns ReportID, County,Dsitrict, DataYears, LastUpdate and LastUpdateBy

Table RubricReportDetail has columns ReportID, IndicatorID, LocalPerf

Kindly help me.

Thanks in advance

View 3 Replies View Related

Delete/insert Vs Update

Jan 22, 2008

Im trying to keep a mirror image of some data Im getting from Quickbooks.

As the records are inserted into the database I need to check if a record exists and either update or insert a new one.

it seems easier just to delete using the tnxid and reinsert vs updating

my question is if I go

begin

INSERT INTO QBInvoicesQue(100s of feilds)

end


begin

delete from QBInvoices where txnid = @TxnID

end

and there is not matching txnid to delete from will it cause any problems? before going to the insert statement?


begin

INSERT INTO QBInvoices(100s of feilds)

end

View 6 Replies View Related

Update / Delete With Joins

Jul 23, 2005

Asking for some sample SQL/SP code to perform updates/deletes with joinedtables.Example 1:For every record that is matched on both tables A and B, update a field intable A.Example 2:For every record that is matched on both tables A and B, delete record intable A.TIA.~ Duane Phillips.

View 2 Replies View Related

Prevent DELETE And/or UPDATE

Jul 23, 2005

Hi all!Are there any other way than using rights or Triggers to prevent aDELETE or an UPDATE on a specific column.The "problem" with rights is that they dont apply to all DB-usersThe "problem" with triggers is that they generate lots of extraSQL-codeI would like a solution something like below. If there are anyprimitives like this or other more neat solutions I would be glad toknowCREATE TABLE some_table NO DELETE/* ^^^^^^^^^*/(some_column SOME_TYPE NO UPDATE/* ^^^^^^^^^*/)For clarity, here is a trigger that currently solves the problemCREATE TRIGGER check_updateable_columns ON some_tableFOR UPDATEASIF UPDATE(some_column)RAISERROR(...)GOorCREATE TRIGGER delete_not_allowed ON some_tableINSTEAD OF DELETEASRAISERROR(...)GO

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved