.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

AccessDataSource ----> SqlDataSource

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net
 
Does anyone know how to convert this AccessDataSource to a SqlDataSource connection?

Thanks.


Code


Private Function GetNotes(ByVal id As String) As Object   Dim ds As New AccessDataSource()   ds.DataFile = AccessDataSource1.DataFile   ds.SelectCommand = String.Format("Select Notes FROM [Employees] WHERE [EmployeeId]={0}", id)   Dim view As DataView = CType(ds.Select(DataSourceSelectArguments.Empty), DataView)   If view.Count > 0 Then   Return view(0)("Notes")   End If   Return Nothing   End Function   Private Function FindImage(ByVal id As String) As Byte()   Dim ds As New A


View Complete Post


More Related Resource Links

How to retrieve data from SqlDataSource and pass to a variable?

  

Hi there,

I have a page in my website where there is very little code-behind. I only have two lines of code in Page_Load() and the rest of the code is declarative ASP.NET code. I have a FormView control which uses a SqlDataSource to get some order information. The SqlDataSource calls a stored procedure called usp_GetOrderDetails, here's the code for the SqlDataSource:

    <asp:SqlDataSource ID="sdsFormOrderDetails" runat="server" 
ConnectionString="<%$ ConnectionStrings:ForexDB %>"
ProviderName="<%$ ConnectionStrings:ForexDB.ProviderName %>"
SelectCommand="usp_GetOrderDetails" SelectCommandType="StoredProcedure"
UpdateCommand="usp_UpdateOrder" UpdateCommandType="StoredProcedure"
>
<SelectParameters>
<asp:ControlParameter Name="orderId" ControlID="grdOrders" PropertyName="SelectedDataKey.Value" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter Name="orderId" ControlID="frmOrderDetails" PropertyName="SelectedValue" />
</UpdateParameters>
</asp:SqlDataSource>

Binding GridView with SqlDataSource at runtime?

  

Hi, I want to create a generic page which contains a gridview and sqldatasource. I want to put these two controls on .aspx (C#) page but bind them at runtime. It should have selectcommand, updatecommand, deletecommand and insertcommand. Stored procedures are created for that. Help is needed to make it. Please post some link or code. Regards, ap.


SqlDataSource how to change the stored procedures at run time

  

Hi

Is it possible to change the select, insert and update stored procedure of an SqlDataSource at run time. I don't mean to change the definition of the stored procedure, but I mean to change the assignment, i.e. To change the select stored procedure from "selectSP1" to "selectSP2" at run time. Is it possible?

Regards

Dimitris


SqlDataSource UpdateCommand using 2 tables

  

I have two tables

Trans  with fields TransID, Date, CustomerID and some other stuff

Customer with fields CustomerID, Name, TaxId

On the screen the user only sees the fields Date and Customer Name. CustomerID is behind the scenes only.

 

I'm using SqlDataSource. Having no problems with SelectCommand. I don't know how to construct the UpdateCommand and InsertCommand.

Let's say the user changes the date, then I need to do an UPDATE.

UPDATE Trans SET Date = @Date, CustomerID = @CustomerID results in an error message and the record is not updated.

I get an error on the page that says "Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in correct format".

 

I tried taking out the set for CustomerID and I still get the error on page.

 

Also, for inserting, the users will see a dropdownlist with Customer Names. I need to convert that to a CustomerID to be used in the new record being inserted in the database. I'm not sure how to do this.

 

Do I need to do something with Control Parameters?


Using SqlDataSource as the Datasource to Accordion

  

Hi,

The accordion does not renders. What am I missing? I want to use a parent child kind of accordion. Perhaps the child is not defined correctly, but I would like to see at list the seven tabs with the name of each organ system show up. The numbers of records for each organ system varies and I need a text box for each organ/tissue to be displayed, so I can insert in a findings table.

Here is what I have

new protected void Page_Load(object sender, EventArgs e)
        {
            ModalPanel.Visible = false;
            ds1 = GetSqlOrganSystems();
            Page.Controls.Add(ds1);
          
        }

protected SqlDataSource GetSqlOrganSystems()
        {

         SqlDataSource dsL = new SqlDataSource();
            dsL.ID = "ds1";
            //#DataBinder.Eval(Container.DataItem,"Organ_System_ID" DataBinder.Ev

SqlDataSource and Parameters query

  

Hi everyone,

I'm on the edge wondering is it possible ? I have got 2 questions. Please help me out.

1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like

SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.

Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).

2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query

(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).

If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.  I am stucked and desparately looking for help. Thanks all.


sqldatasource's filter returns too few records

  

I have a puzzling issue.  This is in asp.net 2.0, using vb.  I have a gridview that is bound to a sqldatasource.  Here is the datasource code:

<asp:SqlDataSource ID="fellowsSqlDataSource" runat="server"
        ConnectionString="<%$ ConnectionStrings:PFPFellowsConnectionString %>"
        ProviderName="<%$ ConnectionStrings:PFPFellowsConnectionString.ProviderName %>"
        SelectCommand="usp_v_fellows2"
        SelectCommandType="StoredProcedure"
        UpdateCommandType="StoredProcedure"
        UpdateCommand="usp_edit_selected"
        FilterExpression="{0}"  >
        <SelectParameters>
            <asp:SessionParameter Name="psuaccessid" SessionField="username" />         
        </SelectParameters>
         <UpdateParameters>

Gridview Update outside of SqlDatasource

  

Is it possible to use a SQLDataSource to populate a gridview but not use the SQLDataSource for Updating?

I wanted to add the update code in the Gridview_RowUpdating event since it is a complex update I need to do.


I get this message when i click the update button


Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.


dropdownlist bound to sqldatasource adds items instead of replacing on change

  

Hello,

I have a series of dropdownlists on webform in ASP 4.0. The first drop down is filled upon load, and then when a user selects a value from that list, it populates the second dropdown. To accomplish this, I have a SQLdatasource with a parametersource of the first drop-down list control. This works great, except when a user changes their selection from the first drop down. It performs the query, but then adds the list of items to the ones that were already there from the previous selection, instead of replacing it with the new data. Here is the code:


 <asp:DropDownList ID="ddlMajor" runat="server" DataMember="DefaultView" 
      DataSourceID="SqlDataSource1" DataTextField="majortext" 
      DataValueField="majorkey" AppendDataBoundItems="True" AutoPostBack="True">
         <asp:ListItem Value="0">Select Major</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlReq" runat="server" DataMember="DefaultView" 
      DataSourceID="SqlDataSource2" DataTextField="req" DataValueField="admreqkey" 
            AppendDataBoundItems="True" AutoPostBack="True">
                <asp:ListItem Value="0">Sel

Return value from SqlDataSource in GridView ?

  
Hi, everyone. I have textbox for searching a Names in My database. I return the information from the Select Statement in  GridView, but i want to know the number of affecter rows. How to do that?

Mapping SqlDataSource Parameters to Formview with Multiple DataKeys

  
Hi I have:a FormView that is linked to SqlDataSource1a Repeater control (inside the formview) that is linked to SqlDataSource2Thus representing a simple "1 to many" or "parent/child" relationship in the database!SqlDataSource1 is simple in that it just retrieves a straight set of records from a table and they are displayed back in the FormView (nothing special happening there). SqlDataSource2 has parameters that  filter the contents of the repeater based on the record that is shown in the Formview. This would normally be simple enough to set up by setting the parameter to the formview.selectedvalue property.HOWEVER - THE PROBLEM ARISES...The formview has multiple DataKeyNames because the table that the SqlDataSource1 links to has a compound key. So to filter the Repeater correctly SqlDataSource2 needs to map 3 parameters to 3 data key values in the formview.Any ideas how to do this?I've tried setting the SqlDataSource2 parameters to:<SelectParameters>   <asp:ControlParameter ControlID="FormView1" Name="Parameter1" PropertyName="DataKey(0)" />   <asp:ControlParameter ControlID="FormView1" Name="Parameter2" PropertyName="DataKey(1)" />   <asp:ControlParameter ControlID="FormView1" Name="Parameter3" PropertyName="DataK

Mapping SqlDataSource Parameters to Formview with multiple DataKeys

  
Hi I have:a FormView that is linked to SqlDataSource1a Repeater control (inside the formview) that is linked to SqlDataSource2Thus representing a simple "1 to many" or "parent/child" relationship in the database!SqlDataSource1 is simple in that it just retrieves a straight set of records from a table and they are displayed back in the FormView (nothing special happening there). SqlDataSource2 has parameters that  filter the contents of the repeater based on the record that is shown in the Formview. This would normally be simple enough to set up by setting the parameter to the formview.selectedvalue property.HOWEVER - THE PROBLEM ARISES...The formview has multiple DataKeyNames because the table that the SqlDataSource1 links to has a compound key. So to filter the Repeater correctly SqlDataSource2 needs to map 3 parameters to 3 data key values in the formview.Any ideas how to do this?I've tried setting the SqlDataSource2 parameters to:<SelectParameters>   <asp:ControlParameter ControlID="FormView1" Name="Parameter1" PropertyName="DataKey(0)" />   <asp:ControlParameter ControlID="FormView1" Name="Parameter2" PropertyName="DataKey(1)" />   <asp:ControlParameter ControlID="FormView1" Name="Parameter3" PropertyName="DataK

Change Sqldatasource or LINQ to SQL into a DataSet? [C#]

  
Hi Everyone,I've saw a couple of threads on here and on different sites around this area but none I've tried have seemed to work.What I'm struggling to achieve is, I want to take a set of results attained by either a SqlDataSource or a LINQ to SQL Method and feed them into a DataSet. Why? This is because I have downloaded an example of a repeater which has paging programmed on it, but in the example it uses the DataSet.ReadXML method to read a pre-defined set of results in an XML file. As my results are constantly changing I thought it would be a good idea for the DataSet to attain them from the previous mentioned ways.I've lost count at the number of ways I've tried it, from setting up SQLConnection method seperately and the QS set as a 'string' then passing that through etc. to simply trying Dataset Items = PartialClass.GetAll(); - Which throws back Generic<List> cannot be converted to DataSet - or something close to that.I'm working from an example and incorporating it into my own project.Below is the code I'm trying to get working:C#:protected void Page_Load(object sender, EventArgs e) { // Call the ItemsGet method to populate control, // passing in the sample data. ItemsGet(); } public void ItemsGet() { // Read sample item info from XML document into a DataSet DataSe

SqlDataSource ControlParameter textBox:Not Working

  
I have a stored procedure that returns 3 searches1) ALL records2) Records staring with something3) Records containing somethingThe stored Proc works finehere is the proc header:CREATE PROCEDURE [dbo].[procGetOHLCSymbolReferenceQuick](@SearchContains VARCHAR(20)='X1234',@SearchStartsWith VARCHAR(20)='X1234')THE ISSUEI have a gridview on a user control, with two texboxes. The gridview is supplied by a SQLDataSource. The textboxes provide that Users Filter demands. The TEXT BOXES<asp:TextBox ID="txtNameStartsWith" runat="server" Width="75px" TextMode="SingleLine"  BackColor="#FFF6CD" /><ajaxtoolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="txtNameStartsWith" FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom"  ValidChars=" @$.^!" /><asp:TextBox ID="txtNameContains" runat="server" Width="75px" TextMode="SingleLine"  BackColor="#FFF6CD" /><ajaxtoolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="txtNameContains" FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom"  ValidChars=" @$.^!" />THE SQLPARAMETERS<SelectParameters&g

SqlDataSource - Update Parameter with javascript

  
Hello, It's possible change the DefaultValue of Parameter with javascript?   Tks

You have specified that your delete command compares all values on SqlDataSource 'SqlDataSource1',

  
hi.am getting the following error .... i have a grid view with a command field ADD(i e INSERT)..... EDIT and DELETE.....edit button works fine but when i click on DELETE its throwing the following errorYou have specified that your delete command compares all values on SqlDataSource 'SqlDataSource1', but the dictionary passed in for values is empty.  Pass in a valid dictionary for delete or change your mode to OverwriteChanges.so can any one help me in this regard...

Chart control with sqldatasource?

  
Hi,I am working with chart controls in VS 2010. I have used sqldatasource. I want to populate select values from sqldatasource and display it on the chart controls.According to the chart samples: http://code.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418the chart controls are databound in the page_load event. Then in which page event should I select data from sqldatasource?Code for sqldatasource selection will also be appreciated.Regards,ap.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend