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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using Data Tables.Select

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :ASP.Net
I am missing something in trying to select a record  from a data table.  
The commented out code works fine but when I modify it to try and use Select. the bold lines, I get an erroron the last line,
"Nutr_Val" is throwing this - Cannot implicitly convert 'string to 'int'.  
Thanks for any help.
strNDB_No = Convert.ToString(cRow["NDB_No"]);
//string strNutr_No = "203";
DataSet dsUSDANUT_DATA = new DataSet();
//string strSql1 = "select * from NUT_DATA WHERE NDB_No = " + "'" + strNDB_No  + "'" + " AND Nutr_No = " + "'" + strNutr_No + "'";
string strSql1 = "select NDB_No, Nutr_No, Nutr_Val from NUT_DATA WHERE NDB_No = " + "'" + strNDB_No + "'";
OleDbDataAdapter daUSDANUT_DATA = new OleDbDataAdapter(strSql1, cn1);

                if (dsUSDANUT_DATA.Tables[0].Rows.Count > 0)
                    //DataRow xRow = dsUSDANUT_DATA.Tables["USDANUT_DATA&q

View Complete Post

More Related Resource Links

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Data Points: Creating Audit Tables, Invoking COM Objects, and More


Dealing with error handling between T-SQL and a calling application, evaluating when a field's value has changed, and creating auditing tables in SQL ServerT are all common issues that developers must tackle.

John Papa

MSDN Magazine April 2004

Use BDC data in list as multi-select column

I have a document library that uses values from another system for its metadata.  Right now, we copy the values from the primary system into SharePoint so users can choose them.  I want to find a way to use the BDC connection that I have set up to automatically pull those values.  The problem is that the current metadata is set to multi-select.  So, I have a file that is in the library and it can be used for multiple clients - clients is a column in my library and users can select many entries.  When I set up a column to pull BDC data, it only allows single entry.  Does anyone have any ideas?

SELECT statement to return NULL by matching data from another table.

Hi,I am fairly new at SQL and I have been struggling for days now trying to find an answer to my problem and i have come to the point where i have run out of ideas and about to give up. I'm hoping someone can put me in the correct path. The problem I have 3 table Table 1 Department" has the following columns: REF, NAME Table 2  "Department_Collection" has the following columns: REF, DEPARTMENT_REF, MANAGER_REF, STORE_REF, ACTIVE Table 3 Store" has the following columns: REF, NAME, STORE_ID  What i am trying to do is to take all the rows in the Department table and get a matching row (DEPARTMENT.NAME, DEPARTMENT_COLLECTION.REF) from the Department_Collection table, if it does not match any then still display DEPARTMENT.NAME but mark DEPARTMENT_COLLECTION.REF as null. I have tried the following select statement but it seem to remove all null values when supplied with a 'storename' SELECT DEPARTMENT.NAME, DEPARTMENT_COLLECTION.REF FROM DEPARTMENT_COLLECTION right outer join DEPARTMENT on DEPARTMENT_COLLECTION.DEPARTMENT_REF = DEPARTMENT.REF left outer join STORE on DEPARTMENT_COLLECTION.STORE_REF = STORE.REF where STORE.NAME = 'storename' order by DEPARTMENT.NAME   Any help will be greatly appreciated. Thanks

Get data from 4 tables

Hi everybody! I have 4 table : A : Guid, name B : Guid, name C : Guid, name D : AGuid, BGuid, CGuid I need to get the table with AName, BName, CName where Aname (or BName/Cname) = x I don't witch join expression I need to use. Can anyone help? Thank you

ASP.NET insertion and joining data between tables

I have the following tables:1.) PRODUCT_INFORMATION2.) CUSTOMERS3.) DISTRIBUTORS4.) PRODUCT_NAME5.) CONTROLLEREach table has a primary key assigned. The customers table has an ID column and a CUSTOMER_NAME column with unique index property set to avoid any duplication. How do I insert values in the product_information table that has a foreign key column from the CUSTOMERS table if we insert a value in the CUSTOMER_NAME field of the CUSTOMERS table. I want to know how can I create a join between all the tables so that when I insert values in individual tables they are joined with a serial number column in the PRODUCT_INFORMATION  table?Please suggest!!

How to select data from xml file

Hi, I have the xml file below....<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0"> <Title>Products</Title> <link rel="self" href="localhost" /> <updated>01-09-2010T11:42:47Z</updated> <author> <Name>Yasmin</Name> </author> <id>tag:localhost,1-9-2010:/support/products</id> <entry Prd_ID="222" Cat="Hell" Type="0" xmlns="http://www.w3.org/2005/Atom"> <id>222</id> <title>Hell is here</title> </entry> <entry Prd_ID="220" Cat="Hell" Type="0" xmlns="http://www.w3.org/2005/Atom"> <id>222</id> <title>heaven2222 is here</title> </entry> <entry Prd_ID="221" Cat="Hell" Type="1" xmlns="http://www.w3.org/2005/Atom"> <id>222</id> <title>heaven is here</title> </entry> </feed> I want to select all nodes with entry[@type=0] and display the first childnode in response.write but dont know how to do it plz help .......   Thanks, Yasmin

Select All on multiple data grids on the same page

Hi gurus, I have two data grids on one page and both have first colums as a check box list. I want to implement a check All button for both the grids independently, now here is the problem I am using the following code to do that and even though I write individual functions for both the grids, when i check the Check All check box for grid one it checks everything on grid one as well as grid two. <HeaderStyle HorizontalAlign="Justify"> </HeaderStyle> <ItemStyle HorizontalAlign="Center" BackColor="Lime"> </ItemStyle> <HeaderTemplate> <asp:CheckBox ID="CheckAll" OnClick="javascript: return select_deselectAll (this.checked, this.id);" runat="server" /> <img src="../Images/email.GIF"> </HeaderTemplate> <script language="javascript"> //checks all DataGrid CheckBoxes with the given name with the given value function select_deselectAll (chkVal, idVal) { var frm = document.forms[0]; // Loop through all elements for (i=0; i<frm.length; i++) { // Look for our Header Template's Checkbox if (idVal.indexOf ('CheckAll') != -1) { // Check if main checkbox is checked, then select or deselect datagrid checkboxes if(chkVal == true) {

Copy data from 2 tables

I have 2 tables. One is more normal and I am trying to find the easiest way to do this. This is a 1 time deal. So the from table These columns; A B C Ak1 Ak2 Ak3 The to table has; A B C One Two Three I want to copy only if ak1 > 0 to the corresponding cols on the 2nd table.*** Please allow me to mark threads as answered and I will, Thank you ***

Use Data in a Column as Select Button in GridView

I don't want to use the built in "Select" hyperlink that's in the gridview, I'd like to just use the first data column, is there a way to do that or are we forced to use the automatically generated "Select" column.Thanks!

Select "Name" from all Tables in SQL Server

I am trying to Select column "Name" from all the Tables in SQL Server     Dim MyConnection2 As New SqlClient.SqlConnection("Data Source=XXX")            Dim mydtadapter2 = New SqlDataAdapter("Select o.name + '.' + c.name from syscolumns c, sysobjects o where (c.name & 128 = 128) and o.name = c.name order by o.name", MyConnection2)            Dim ds As New DataSet            mydtadapter2.Fill(ds, "name")                                  clientname2.DataSource = ds.Tables("name").DefaultView            clientname2.DataBind()

Select column from all tables in database

I want to retrieve the name and phone columns from all the tables in my database not in systables....   Ok this works but i dont want to get it from just the test table I want to get it from all the tables that I create "USE mrpoteat SELECT name, phone FROM mrpoteat.dbo.test where name = name and phone = phone"

Select necessary data from Gridview row

Is it possible to select a row without using the SELECT hyperlink/button besides I don't want to slect the entire row instead, i can select the row of the checked radio button? Based on this example image, I just want to retrieve the data from column FROM, TO, FLIGHT and the selected radio button which is PHP 2899.00.

XSL Lookup to another List in a View. Joining in data from another List. xsl:value-of select=

I've been able to create a DataView with data joined from two SP Lists. I did this using SPD, a linked Source, and doing joined subviews.  The technique works nicely, but I have to create my DataView from scratch.As an alternative, I took an existing AllItems View in SPD, converted it to XSL, and was able to add a column from another List as follows:   <TD Class="{$IDA1VDGH}" style="width: 62px; height: 23px"><xsl:value-of select="/dsQueryResponse/Master/Rows/Row/@Lastname" />The problem is, it reports the column for the first row everytime. I'm new to XSL and was wondering..    using XSL, and preserving all the original columns already in the View, is there anyway to make the added column smarter, maybe with a filter?I noticed in my working example, I have this filter (I guess where the subview join magic is)            [@Title = $dvt_ParentRow/@Key] which does not resolve syntax:I tried this, but it does not work, only finding one match, and it also seems to get set for the entire Dataview and not just the column.     [../../../Master/Rows/Row/@Title = @Key] I guess I'm looking either for the SPD steps, or XSL code for adding a single column from another list, joined in by a column in both lists.Thanks for any help or information.

Import a flat file with combined data into separate SQL tables using SSIS

I have a flat text file (comma delimited) that is essentially multiple files, each with its own format, combined into one file. The file is coming from an external software vendor so unfortunately we don't have much choice but to work with what we are receiving. Here is an example of what the file could look like: Customer Data CustID,FName,LName,PhNum,Email 12345,John,Smith,,jsmith@gmail.com 12346,Jane,Doe,8001111111,jdoe@hotmail.com Customer Plan CustID,PlanType,PlanName,PlanStart 12345,0,Plan1,01/01/2010 12345,2,PlanVis,01/01/2010 12346,3,PlanLf,04/01/2010 12346,0,Plan1,01/01/2010 Customer Payment CustID,LastPayment,Amount 12345,09/01/2010,100.00 12346,05/01/2010,50.00 There is an empty line between each 'section' of data. I adapted a VB script I found online that can take the incoming file and save off each section as its own file so that each one can be separately imported, but this seems inefficient. I'm really new to SSIS in general, but it seems like it shouldn't be that difficult to take the data, split it where there is an empty line, and then import each section into the appropriate SQL table. Any ideas would be most welcome. Thanks!  

Error: "Select statements included within a function cannot return data to a client"

hi all, Not sure if there is an easier way to do this but this is my first ever Function I created so far. I am getting the error: "Select statements included within a function cannot return data to a client" All I am trying to do is ...if the date is NOT passed then apply NULL as the default value and run the SELECT statement. If the date IS NOT null then run a different SELECT statement. CREATE FUNCTION [SchemaTest].[fn_Test] ( @instance as uniqueidentifier ,@date as datetime = null ) RETURNS varchar(8000) AS BEGIN If (@date is null) --@date = null ?? Begin Select * From Uds.RealtimeLogging Where instanceID = @instance End Else Begin Select * From Uds.RealtimeLogging Where instanceID = @instance and [timeStamp] > @date End Return @stepIds END Thank you!JCD

compare data from tow tables ?

HI all I have tow tables ,, i want to add Column1 from table1 to Column1 in table2 , where Column2 in table1 is bigger than Column2 in table2
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