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


Post New Web Links

better code for select in a typized dataset

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :ASP.Net
 

hi there
i have a dataset in my project named  DS.xsd
so, i usually take a dataTable using this code:


        Dim da As New DSTableAdapters.RistorantiTableAdapter
        Dim DT As New DataTable("Ristoranti")
        Dim DR As DS.RistorantiRow()

        DR = da.GetData.Select("codRistorante=" & HID_Risto.Value)
        Dim drr As DS.RistorantiRow = DR(0)

        With drr
            If .IsCAPNull = False Then TXT_Cap.Text = .CAP
            If .IsCategoriaNull = False Then TXT_Categoria.Text = .Categoria
......

i think it is obsolete code
and i use 5 rows of code for take my data
is it correct? or may i use another approach for doing it better?




View Complete Post


More Related Resource Links

Iterate through rows of dataset in report's custom code

  
Hello, How can I iterate through the rows of a dataset in the custom code? I have a report containing a dataset. I pass the dataset as a parameter to the custom code function. But what then? Where is a reference about the available members etc.? Here is my dummy sample code so far: Public Function ShowParameterValues(ByVal ds as DataSet) as object() Dim codes() As Object Array.Resize(codes,dc.???.Count) codes(0)=ds??(field???)(row??) return codes End Function As the task I want to accomplish is very simple, I want to keep it in the custom code instead of writing any custom assemblies etc.   Thank you!

Creating Code Function or Assemblies to manipulate Dataset

  
Folks In SSRS the dataset, can it be send to a Code function for further manipulation of the data ? For example, In SSRS I have a Column of Data and I want to passed it to a Code Function, and the code function for certain values and perform some Engineering calculation, and the function than return a modififed dataset. Can I do this ? Thanks in Advance  

How to add Select Control parameters in Code Behind

  

I have a need to add my page controls dynamically in code behind.

I do well, adding a dropdownlist, a SQL datasource to populate it, setting it to autopostback=true, and adding a gridview and its SQL datasource.

What I'm unsure about is how to programmatically refer to the SelectParameter, being a control (the DropDownList), and its selected item.

any ideas? 


How to select only one row from DataSet

  

Hi,

My DataSet gives a result like this when i bind to GridView


BillNo     BillStation            Amt1         Amt2       Amt3       Amt4

Hyd

 1              Hyd                  100              50          50           25

 2              Hyd                  100              50          50           25

Bang 

 2              Bang                500            100        200           50 

 2              Bang                500            100        200           50

Delhi

 3     &n

SQL SELECT in my code which doesn't like 2 words

  

SELECT * FROM tblstock WHERE Devicestatus=('Active') AND Model like '%"&criteria &"%'

The statement above is a snippit from my code. My problem is that the search won't understand a space between say two words.?

so if the user puts in DELL COMPUTER it won't return anything!?  But if they put in DELL on its own it finds the record that says DELL COMPUTER?!!

I'm just a bit confused that's all... Anybody know how I can get around this?


Many thanks




What is the code to say if the select statement of sqldatasource1 control has no record, then..

  

What is the code to say:-

 if the select statement of sqldatasource1 control has no record, then..

Pls help... thanks

 

 

 


Dataset select issue

  

Hi there,

I have written some code using data sets (which i am new to). I have brought back all of the rows, which is fine, but i need to select certain customers according to if they are active

SqlConnection cnn = new SqlConnection(@"Data Source=192.168.100.2;Initial Catalog=intranet;User ID=sa;Password=xxxxx;");
        SqlDataAdapter cmd1 = new SqlDataAdapter("select * from clients WHERE active = 1", cnn);

        DataSet ds = new DataSet();
        cmd1.Fill(ds, "clients");

        SqlDataAdapter cmd2 = new SqlDataAdapter("select * from tbl_imalive", cnn);
        cmd2.Fill(ds, "tbl_imalive");

        ds.Relations.Add("myrelation",
        ds.Tables["clients"].Columns["id"],
        ds.Tables["tbl_imalive"].Columns["customerID"]);

        parentRepeater.DataSource = ds.Tables["clients"];
        Page.DataBind();

&nb

Dataset.tables.Select method

  

I want to select student who belogs to New York.so this purpose i write query as

ds.Tables("student").select("city==NewYork"); it is not work

where

"ds" is dataset

"city" is column name

"New York" is the string

Can anybody help me? 

Give me suggestion 


Gridview not updating when SQL has select statement in code behind

  

I have a gridview with a sql datasource. When the select statement for the datasource is in the sqldatasource control then everything works fine and i can view the data and update it through the gridview. When I take away the selecet statement and insetad use a sqldatasource.SelectCommand in my code behind then I can only view the data in the gridview but cannot edit. When I try to edit/update data the data being edited goes back to original and the gridview stays in edit mode. After hitting cancel on the gridview then the old data still shows. Any ideas about this? "Optimistic Concurncy" is also switched off so that is not the problem.


Code Optimized Web Development Profile (VS 2010 and .NET 4.0 Series)

  
When you first run VS 2010 it prompts you to select an IDE profile to use. The profile you select will configure how tool windows are displayed/docked in the IDE by default and set the default keyboard shortcuts. You can then customize any of these settings by using the Tools->Options menu within the IDE and then override/change them. You can also later reset your profile and pick a different one by choosing the Tools->Import and Export Settings menu command.

Free Code Snippets - ASP.NET

  
You Can Find Useful ASP.NET Related Posts on the above link.

Free Code Snippets - C#

  
Free C# Code Snippets

AJAX GridView Checkbox Select All in ASP.Net

  
In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side

Microsoft StyleCop: Source Code Analyzer for C#

  
StyleCop is similar in many ways to Microsoft Code Analysis (specifically FxCop), but there are some important distinctions. FxCop performs its analysis on compiled binaries, while StyleCop analyzes the source code directly. For this reason, FxCop focuses more on the design of the code, while StyleCop focuses on layout, readability and documentation. Most of that information is stripped away during the compilation process, and thus cannot be analyzed by FxCop.
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