Sqldatasource Data In Code Behind

Apr 21, 2006

I have a sqldatasource in the markup. This is in turn connected to a Gridview. I use Eval to retrieve the database information in the markup but I also need the Eval information in code behind.  How can I do this?

I got this far but how (if it's possible this way) can I retrive it?

Protected Sub Test(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

If (e.Row.RowType = DataControlRowType.DataRow) Then

this is where i want to get the "MyData" value from the database.

End If

........

 

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"

DataKeyNames="test" DataSourceID="SqlDataSource1" UseAccessibleHeader="False" GridLines="None" ShowHeader="False">

<Columns>

<asp:TemplateField>

<ItemTemplate>   





<asp:HiddenField ID="Hiddenvalue" runat=server Value='<%# Eval("MyData") %>' />

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

 

using VB..

 

 

View 1 Replies


ADVERTISEMENT

How Do I Access Sqldatasource Data Values In Code Behind?

Jan 1, 2006

How do I access sqldatasource data values in code behind and bind them to strings or texboxes etc. as oposed to using Eval in the markup?
I can create a new database connection, but I would like to use the data values from the autogenerated sqldatasource control
Many thanks,

View 1 Replies View Related

Putting SqlDataSource Code In Code-behind

Jan 25, 2007

Hi,I need some help here. I have a SELECT sql statement that will query the table. How do I get the return value from the sql statement to be assigned to a label. Any article talk about this? Thanks  geniuses.  

View 2 Replies View Related

Sqldatasource In Code-behind

Dec 30, 2006

How do I programically (in the code-behind-file) assign a value from the database to a variable using a sqldatasource?...
I will do something like this:
Dim MyCity as string = SqlDataSource.MyCityColumnInTheDatabase 
(The sqldatasource select everything in my "CityTable") 
Hope you understand what I mean...

View 5 Replies View Related

Sqldatasource +code Behind

Mar 13, 2007

i have an sqldatasource which runs a select command. How does one access the results in the codebehind, that is on page load set Label1 to value returned from the datasource. Please note that there will only ever be one value returned by the datasource This is fairly urgent so any help is needed quick thanks in advanceIlan 

View 2 Replies View Related

SQLDatasource Code Behind

Mar 3, 2006

Can you access a SQLDatasource in the code-behind?
Example: label1.text = sqldatasource.field
I am just migrating apps to ASP.NET 2.0...
Confused as to the best approach for paramaterized data access and binding to labels.
 

View 3 Replies View Related

In Line Code In &<asp:SqlDataSource

Jun 16, 2006

Hi,
 
I have a problem with the <asp:SqlDataSource.  The thing that I try to do is to create a SQL  statement.  I am not sure if this can be done or not ( just started asp.net).
 
Something like this:
 
<%
    Dim Test1 As String
    Dim Test2 As String
    Dim Test3 As String
    Dim Test4 As String
   
    Test1 = Request("xmbr")
    Test2 = Request("xSEL")
    Test3 = Request("xpro")
    Test4 = "SELECT [jedan], [dva], [tri], [cetiri], [pet] FROM [pet1] where " & (Test1) & " " & (Test2) & "'" & (Test3) & "'"
  
%> 
 
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FinGateConnectionString %>" SelectCommand="<%= Test4%>">
 
 
The problem is that is giving me an error that I can’t figure out.
 
-------------------------------------------------
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '<'.Source Error:





An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 -------------------------------------------------
 
Thanks.
 
Nbdg_28

View 2 Replies View Related

SqlDataSource - Where To Put It ? On The Page - In The Code Behind ?

Nov 19, 2006

Hi,
I have the following Sql Data Source that I wish to bring back on my page:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FrogConnectionString %>"
SelectCommand="ProposalsCheckNewCustomerData" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:FormParameter FormField="MaritalStatusID" Name="MartialStatusID" Type="Int32" />
<asp:FormParameter FormField="LivingStatusID" Name="LivingStatusID" Type="Int32" />
<asp:FormParameter FormField="DealerID" Name="DealerID" Type="Int32" />
<asp:FormParameter FormField="VehicleTypeID" Name="VehicleTypeID" Type="Int32" />
<asp:FormParameter FormField="FinanceTypeID" Name="FinanceTypeID" Type="Int32" />
<asp:FormParameter FormField="MediaSourceID" Name="MediaSourceID" Type="Int32" />
<asp:FormParameter FormField="DealerContactID" Name="DealerContactID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
The recordset brings back 7 values that I wish to populate into 7 Labels.
1. Should the SqlDataSource be on the page (between the Head tags) or within the Page_Load command of the Page Behind ?- If its on the page behind do any of you have any sample code to show me how to get the recordset up and running ?
2. How would I bind the results to a label ?- Within my old asp pages it was simple (I'm not saying its not simple here, I am still getting my head around vb.net)- eg <%=rsX("MaritalStatus")%> I guess its something very similar
Thanks for any pointersFizzystutter
 

View 4 Replies View Related

How Can I Bind To An SqlDataSource From Code

Feb 18, 2007

My code behind file builds a select statement and I would like to fill an SqlDataSource control with it. Can some show me an example of how I might do that? Maybe something like this?
Me.SqlDataSourceSearchResult.ConnectionString = "ConnectStr"
Me.SqlDataSourceSearchResult.SelectCommand = "SelectStatement"
gvSearchResult.DataSource = Me.SqlDataSourceSearchResult
gvSearchResult.DataBind()

View 5 Replies View Related

Accessing SqlDataSource's Value In Code Behind

May 30, 2007

Hi guys,

I have following query in stored procedure  Select ContractId, Version, CreateDate, body, IsCurrentFrom CRM_Contracts where ContractId=@ContractId I am trying to access the value of IsCurrent field in Code behind using sqlDataSource to hide a radiobutton list in Formview control's when it is in Edit Mode.  How can i do this.  

View 1 Replies View Related

Manage A SqlDataSource In Code Behind (VB.Net)

Dec 30, 2007

Hi All
 It´s my DropDownList data source from my page1.aspx:
<asp:DropDownList ID="ddlChampionships" runat="server" DataSourceID="sdsSearchChampionships" DataTextField="name" DataValueField="id_championship">     </asp:DropDownList><asp:SqlDataSource ID="sdsSearchChampionships" runat="server" ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Tupi_Campeonatos]"></asp:SqlDataSource>
When I put a new championship name in a TextBox and click on the button "ADD", this button event click is called:
 Protected Sub btAddChampionship_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btAddChampionship.Click
     insertNewChampionshipIntoDataBase()
End Sub
The Page then reloads but my DropDownList is not updated. The way I found to do it is to put the DDList update code after the calling of the insertNewChampionshipIntoDataBase() method, but how???
thnx

View 2 Replies View Related

Set SqlDataSource In Code Behind File

Jan 11, 2006

Hello!
I would like to set the SqlDataSource in the code behind file and not to have it in the aspx file. How can I do that?
Regards,
Gato Gris

View 1 Replies View Related

Passing Parameters For SqlDataSource From Code Behind

May 25, 2007

Hi All, Maybe because it's Friday afternoon and I can't think clearly anymore... A really (I guess) simple problem: DataView with SqlDataSource <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">            <ItemTemplate>                <asp:Label ID="id" runat="Server" Text='<%# Eval("ID")%>' />            </ItemTemplate>        </asp:DataList>        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"                SelectCommand="GetItem" SelectCommandType="StoredProcedure">         </asp:SqlDataSource> Now, what I have to do is to pass two parameters to the stored procedure: 1) ProviderUserKey2) Int ValueBut the question becomes "how"?Even if I define:  <SelectParameters>                <asp:Parameter Name="I_GUID"  />                <asp:Parameter Name="I_TYPE" Type="Int32" DefaultValue="1" />            </SelectParameters>I need to set the parameters from code behind.... Thanks for any suggestions Adam  

View 8 Replies View Related

SqlDataSource Pass Parameters From Code-behind

Jul 15, 2007

how do i pass the paramenters and storedprocedure to dataview from code-behind?
the below code have sqldatasource control but i want to pass through code-behind everything...
 
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display." DataKeyNames="NewsId">
<Columns>
<asp:BoundField DataField="NewsId" HeaderText="NewsId" InsertVisible="False" ReadOnly="True"
SortExpression="NewsId" />
<asp:BoundField DataField="PostDate" HeaderText="PostDate" SortExpression="PostDate" />
<asp:BoundField DataField="PostedBy" HeaderText="PostedBy" SortExpression="PostedBy" />
<asp:BoundField DataField="PostedByName" HeaderText="PostedByName" SortExpression="PostedByName" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" />
<asp:BoundField DataField="LastUpdated" HeaderText="LastUpdated" SortExpression="LastUpdated" />
<asp:CheckBoxField DataField="IsVisible" HeaderText="IsVisible" SortExpression="IsVisible" />
</Columns>
</asp:GridView> i have storedprocdure which accepts 4 parameters 3 paramenters which user will supply and 1 parameter will be supplied from code-behindwhat i mean by that is:the 4 parameters storedprocedure accepts is:empid, start_date, end_date (user will supply those 3 parameters)internal_id - which internally pass along with other 3 parmeterssomething like this:internal_id, empid, start_date, end_dateany thoughts?thanks.

View 3 Replies View Related

How To Access SqlDataSource Fields From Code?

Aug 18, 2007

I have <asp:SqlDataSource> in aspx page that is being used by an updateable GridView.  However, there are a couple fields in the dataset that contain filenames that I want to access directly in code and place them into some image tags on the page. This line should give me access to the dataset but how to I access the fields?
Dim myDataSource As DataView = DirectCast(SqlDataSourceGridView.[Select](DataSourceSelectArguments.Empty), DataView)
When the SqlDataSource is a DataReader I would access it with the code below but since this SqlDataSource is a DataSet I can't access it with this code.If myDataSource.Read Then   If Convert.IsDBNull(myDataSource("CusAgentPhoto")) Then      ImageAgent.ImageUrl = "/photos/nophoto.gif"   Else      ImageAgent.ImageUrl = AgentImagePath & myDataSource("CusAgentPhoto").ToString   End If   If Convert.IsDBNull(myDataSource("CusCompanyLogo")) Then      ImageCompany.ImageUrl = "/photos/nophoto.gif"   Else       ImageCompany.ImageUrl = OfficeImagePath & myDataSource("CusCompanyLogo").ToString   End IfEnd If What would be the correct way to get at the DataSet fields that contain the filenames?

View 2 Replies View Related

Sqldatasource Filterexpression In Code Mode

Apr 14, 2008

I have wrote some codes as follows: 
        Dim sqldatasource3 As New SqlDataSource        sqldatasource3.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("aspnetConnectionString").ConnectionString        sqldatasource3.SelectCommand = "select stepno,steppersontype,stepname,steptype,fchoice,fforward,schoice,sforward from flow "        sqldatasource3.FilterExpression = "stepname = '" & GridView1.SelectedRow.Cells(4).Text.Trim & "'"        sqldatasource3.DataSourceMode = SqlDataSourceMode.DataSet        Dim dv As DataView = sqldatasource3.Select(DataSourceSelectArguments.Empty())        dv.RowFilter = "stepname = '" & GridView1.SelectedRow.Cells(4).Text.Trim & "'"
but i found the filterexpression didn't work. No matter what value GridView1.SelectedRow.Cells(4).Text.Trim be,sqldatasource always return the whole dataset.I wanna know where these code are wrong? Can anyone help?

View 1 Replies View Related

SqlDataSource Call Stored Procedure In Code-behind

Jul 14, 2006

Can someone show me how to use SqlDataSource to call stored procedure in a c# class (a support class for aspx) and not in aspx or code-behind?

View 20 Replies View Related

How Do I Pass A Parameter To A Sqldatasource In A Code Behind Page

Feb 1, 2007

i have a sqldatasource on my asp.net page -- select * from table where id = @id
i want to set the @id in the backend and set the result to textbox1.text
how do i do this?

View 1 Replies View Related

Change Dynamically(via Code) The SqlDataSource For A GridView....

Mar 7, 2007

Hi,
say I have two Sqldatasources objects:SqlDataSource1 and SqlDataSource2....
Does anybody know how can I alter programmatically these two sqldatasources in a gridview?
Thanks!!!

View 3 Replies View Related

Sending Parameter To Sqldatasource In Code Behind File

Aug 15, 2007

hi, i have a .aspx.cs code page file and i wanna to send some parameters to sqldatasource in page_load event.i wrote this line of code but it errors that the System.Web.UI.Webcontrols.parameters is a type and not a namespace.here my code:</p><p>&nbsp;</p><pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 226px; text-align: left;">if (Session["membartype"].tostring() == "siteadmin1") SqlDataSource1.SelectCommand ="SELECT DocumentID, DocumentCode, DocumentDate,RequestCode, Delivery, Expr1,CityCode, Title FROM (SELECT dbo.EnterDocument.DocumentID, dbo.EnterDocument.DocumentCode, dbo.EnterDocument.DocumentDate,dbo.EnterDocument.RequestCode, dbo.EnterDocument.Delivery, dbo.EnterDocument.EnterType AS Expr1,dbo.EnterDocument.codecity AS CityCode, dbo.Location.Title FrOM dbo.Location RIGHT OUTER JOIN dbo.EnterDocument ON dbo.Location.codecity = dbo.EnterDocument.codecity) AS T1";ParameterCollection parameter=new ParameterCollection[7]; parameter.Add(DocumentID,text,TextBox1.Text); parameter.Add(DocumentCode,text,TextBox4); parameter.Add(FromDocumentDate,text,TextBox6); parameter.Add(untilDocumentDate,text,TextBox5); parameter.Add(PersonID,SelectedValue,DropDownList2); parameter.Add(EnterTypeID,SelectedValue,DropDownList3); parameter.Add(usercode,String,usercode); SqlDataSource1.SelectParameters.Add(parameter); GridView1.DataBind();</pre><p>  thanks,M.H.H 

View 2 Replies View Related

SqlDataSource Use Code Behind Variables In Update Command

Apr 14, 2008

Is there any way I can use a variable from my code behind file in the UpdateCommand of a sqlDataSource? I have tried
<%$ strUserGuid %>and<% strUserGuid %>
any help appreciated.Thanks
 Dave

View 2 Replies View Related

GridView Update, With SqlDataSource UpdateCommand Set From Code-behind. (C#)

Mar 9, 2006

Hi all
I have a GridView on an aspx page, that is enabled for editing, deletion and sorting.
In the Page_Load event of the aspx page, i add a SqlDataSource to the page, and bind the source to the GridView.
When i click the update, or delete button, it makes a PostBack, but nothing is affected. I'm sure this has got something to do with the parameters.
First, i tried having the GridView.AutoGenerateColumns set to True. I have also tried adding the columns manually, but no affect here either.
The code for setting the commands, and adding the SqlDataSource to the page are as follows:
            string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;            string strProvider = ConfigurationManager.ConnectionStrings["ConnectionString"].ProviderName;            string selectCommand = "SELECT * FROM rammekategori";                        SqlDataSource ds = new SqlDataSource(strProvider, strConn, selectCommand);            ds.ID = "RammeKategoriDS";            ds.UpdateCommand = "UPDATE rammekategori SET Kategoribeskrivelse = @Kategoribeskrivelse WHERE (Kategorinavn = @Kategorinavn)";            ds.DeleteCommand = "DELETE FROM rammekategori WHERE (Kategorinavn = @Kategorinavn)";                        Parameter Kategorinavn = new Parameter("Kategorinavn", TypeCode.String);            Parameter Kategoribeskrivelse = new Parameter("Kategoribeskrivelse", TypeCode.String);            ds.UpdateParameters.Add(Kategorinavn);            ds.UpdateParameters.Add(Kategoribeskrivelse);            ds.DeleteParameters.Add(Kategorinavn);
            Page.Controls.Add(ds);
            SqlDataSource m_SqlDataSource = Page.FindControl("RammeKategoriDS") as SqlDataSource;
            if (m_SqlDataSource != null)            {                this.gvRammeKategorier.DataSourceID = m_SqlDataSource.ID;            }
As mentioned - no affect at all!
Thanks in advance - MartinHN
 

View 4 Replies View Related

Using SqlDataSource To Execute A Select Statement In The Code File???

Nov 27, 2006

Hi you all,
In abc.aspx, I use a GridView and a SqlDataSource with a SelectCommand. The GridView's DataSourceID is the SqlDataSource.
In abc.aspx.cs, I would like to use an IF statement in which if a criterion is not satistied then I will use the SqlDataSource with another SelectCommand string. Unfortunately, I have yet to know how to write code lines in order to do that with the SqlDataSource. Plz help me out!

View 1 Replies View Related

Performance Comparison - Code Vs SqlDataSource, Gridview Etc Vs PlainControl

Jun 9, 2007

There are so many ways to use database in asp.net/ado.net, I'm a bit confused about their difference from the performance point of view.So apparently SqlDataSource in DataReader mode is faster than DataSet mode, at a cost of losing some bolt-on builtin functions.What about SqlDataSource in DataReader mode vs manual binding in code? Say creating a SqlDataSource ds1 and set "DataSourceID" in Gridview, vs manually creating the SqlConnection, SqlCommand, SqlDataReader objects and mannually bind the myReader object to the gridview with the Bind() method.Also Gridview is a very convenient control for many basic tasks. But for more complex scenarios it requires lots of customization and modification. Now if I do not use gridview at all and build the entire thing from scratch with basic web controls such as table and label controls, and mannually read and display everything from a DataReader object, how's the performance would be like compared to the Gridview-databind route?

View 3 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

Master Data Services :: Error Code 8 While Loading Data From MDS Stage To Model

Apr 22, 2015

I am getting ErrorCode 8 while loading the data from stage to model. I have checked my error view it states that "Member Code is Inactive".

Initially I have loaded same set of data in Model from MDS Stage table but then deleted with ImportType = 5 which removed all the data from the MDM model.

Now i want to load it back but its giving the Error Code 8 ..  Before loading the same data i have changed the stage table Importtype to 2 and Importstatusid to 0.

View 6 Replies View Related

Re-use Data From SqlDataSource

Dec 11, 2006

I have a page containing a FormView, which gets its data from a SqlDataSource control and displays details of a job.  Two of the fields are location and job title.  I want to re-use this data to create a dynamic page title.  I know I can do this by setting the Page.Title to what I want to,  but do I have access to the data outside of the FormView to which the data source is bound?  If so how?   Or will I have to perform an additional SELECT statement to get this data again?

View 2 Replies View Related

Using The SqlDataSource To Get Data .net 2.0

Feb 14, 2006

I am used to using asp.net 1.1
and I want to do the equivilent of the following with an SqlDataSource


da.fill(dst1)
lbl.text=dst1.tablename(0).fieldname


and what this does is fills the dataset with the information from the select command in the dataadapter and then gets the value for the first row of the fieldname

It doesnt seem like this should be that big of a deal, but it has become very frustrating trying to find the answer, does anyone know how to do this? Please post some demo code if possible

View 2 Replies View Related

Using Data From SqlDataSource

Mar 9, 2006

Hi Everybody,I have an ordinary SqlDataSource on my page <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:P4SConnection %>"                ProviderName="<%$ ConnectionStrings:P4SConnection.ProviderName %>" SelectCommand="SELECT CO_Id,CT_Name,CO_Username,CO_Password,CO_Company,CO_Email,CT_Id,CT_Position,CT_Admin,                CO_Session,CO_LastLogin FROM company_contact LEFT JOIN company ON company_contact.CT_Company = company.CO_Id WHERE (CT_Username= & LCase(txtName.Text) & ">            </asp:SqlDataSource>How do i use any of these values?I know I can display the values in a GridView or something but I dont want to display them.I originaly was using ODBC and just used the followingDim Row As DataRow = thisTable.Rows(0)            Dim lP_ID As String = Row(0).ToString()            Dim TheContact As String = Row(1).ToString()            Dim theName As String = Row(2).ToString()            Dim thePassword As String = Row(3).ToString()            Dim TheCompany As String = Row(4).ToString()            Dim TheEmail As String = Row(5).ToString()            Dim lP_ContactID As String = Row(6).ToString()            Dim ThePosition As String = Row(7).ToString()            Dim bAdmin As Boolean = Row(8).ToString()            Dim sP_Session As String = Row(9).ToString()            Dim sP_Last As String = Row(10).ToString()Then I could use the values wherever I wanted.How do I do this with a SqlDataSource?Thanks,G

View 4 Replies View Related

How To Retrieve Data From Sqldatasource?

Jul 18, 2006

Okay, I used the SQLDataSource control to get my data from the database
table. What or how do I retrieve individual data from the
sqldatasource? I want to do some string comparison and manipulation
before I display it to the browser. How can this be accomplish?

Help is appreciated.

View 21 Replies View Related

Filtering Data Using Sqldatasource

Oct 12, 2006

i HAVE TRIED THE FOLLOWING CODE BUT ITS NOT WORKING AS I WANT TO FILTER IT ACCORDING TO THE VALUE OF DROPDOWNLIST  I HAVE TRIED CONFIGURE THE SQLDATASOURCE. DATASOURCE MODE PROPERTY IS SET TO THE DATASERSTILL IT IS NOT SHOWING ANY RESULTS <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Untitled Page</title></head><body>    <form id="form1" runat="server">    <div>        <h3>Search Jobs</h3>         <table cellspacing="10">                      <tr>            <td valign="top" style="height: 162px">              <table border="0">                <tr>                  <td valign="top" style="width: 70px">                      Location</td>                  <td><asp:DropDownList runat="server" id="CountryListBox" AppendDataBoundItems="True"                                        DataSourceID="CountrySqlDataSource"                                         DataTextField="location" DataValueField="location" AutoPostBack="True" >                        <asp:ListItem Selected="True" >(Show All)</asp:ListItem>                      </asp:DropDownList>                  </td>                </tr>                <tr>                  <td style="width: 70px">                      Skills</td>                  <td><asp:TextBox runat="server" id="LastNameTextBox" Text="*" /></td>                </tr>                <tr>                  <td style="width: 70px"></td>                  <td><asp:Button runat="server" id="FilterButton" Text="Filter Results" /></td>                </tr>              </table>            </td>             <td valign="top" style="width: 587px; height: 162px;">                              <asp:GridView ID="EmployeesGridView"                DataSourceID="SqlDataSource2"                 DataKeyNames="employeeID"                AutoGenerateColumns="False"                AllowSort="True"                RunAt="server" Height="143px">                                <HeaderStyle backcolor="Navy"                  forecolor="White"/>                                  <RowStyle backcolor="White"/>                                <AlternatingRowStyle backcolor="LightGray"/>                                <EditRowStyle backcolor="LightCyan"/>                  <Columns>                      <asp:BoundField DataField="employeeID" HeaderText="employeeID" ReadOnly="True" SortExpression="employeeID" />                      <asp:BoundField DataField="employeeName" HeaderText="employeeName" SortExpression="employeeName" />                      <asp:BoundField DataField="companyName" HeaderText="companyName" SortExpression="companyName" />                      <asp:BoundField DataField="jobSkills" HeaderText="jobSkills" SortExpression="jobSkills" />                      <asp:BoundField DataField="experiance" HeaderText="experiance" SortExpression="experiance" />                      <asp:BoundField DataField="location" HeaderText="location" SortExpression="location" />                  </Columns>              </asp:GridView>            </td>                          </tr>                    </table>                    <asp:SqlDataSource ID="CountrySqlDataSource"           SelectCommand="SELECT DISTINCT location FROM tlbEmployee"          EnableCaching="True"          CacheDuration="60"          ConnectionString="<%$ ConnectionStrings:ConnectionString %>"          RunAt="server" />         <asp:SqlDataSource ID="EmployeeDetailsSqlDataSource"           SelectCommand="SELECT * FROM [tlbEmployee] WHERE (([location] LIKE '%' + @location + '%') AND ([jobSkills] LIKE '%' + @jobSkills + '%'))"          EnableCaching="True"          CacheDuration="60"          ConnectionString="<%$ ConnectionStrings:ConnectionString %>"          FilterExpression="location LIKE '{0}' AND jobSkills LIKE '{1}'"          RunAt="server">           <FilterParameters>            <asp:ControlParameter ControlID="CountryListBox"   PropertyName="SelectedValue" />            <asp:ControlParameter ControlID="LastNameTextBox" PropertyName="Text" />          </FilterParameters>            <SelectParameters>                <asp:ControlParameter ControlID="CountryListBox" Name="location" PropertyName="SelectedValue"                    Type="String" />                <asp:ControlParameter ControlID="LastNameTextBox" Name="jobSkills" PropertyName="Text"                    Type="String" />            </SelectParameters>        </asp:SqlDataSource>        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"            SelectCommand="SELECT DISTINCT location FROM tlbEmployee"></asp:SqlDataSource>        </div>        <asp:SqlDataSource ID="SqlDataSource2" runat="server"></asp:SqlDataSource>    </form></body></html> 

View 1 Replies View Related

Get Data From SqlDataSource For Selected Row

Feb 24, 2007

Hello all! How can I get data from SqlDataSource for row selected in GridView?

View 3 Replies View Related

How To Access Data Using SqlDataSource

Aug 27, 2007

Hello all,I have what I think should be a simple problem to solve but I just don't quite understand what to do (.NET Framework Developer Center confused me :( ).My code should load the highest SiteID, known as Last_ID into the siteIdBox when the form is in insert mode.  My difficulty is in understanding how to use the sqlDataSource correctly.  Dim dsLastId As New SqlDataSource() Dim siteIdBox As TextBox Dim dsmLastId As SqlDataSourceMode If FV_Site.CurrentMode = FormViewMode.Insert Then Try
dsLastId.ConnectionString = ConfigurationManager.ConnectionStrings("AquaConnectionString1").ToString dsLastId.SelectCommandType = SqlDataSourceCommandType.Text dsLastId.SelectCommand = "SELECT MAX(Site_ID) AS Last_ID FROM Tbl_Site"

dsmLastId = SqlDataSourceMode.DataReader

siteIdBox.Text = dsmLastId.?????

Finally
dsLastId = Nothing End Try End If  If anyone could tell me the code for getting the value from the select statement into the textbox, I would be most grateful.Thank you, m00sie. 

View 4 Replies View Related







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