DataTable Is Always Returns Empty Values?
Feb 17, 2011
I'm .NET newbie and I have to write function which executes stored procedure and return DataTable.
my SqlConnection is already initialized and while running in debugger I can see DataAdapter returns values, but my DataTable is empty.
public DataTable ExecStoredProcedure(String spName, String uId)
{
DataTable dt = new DataTable();
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(spName, conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UnitIDList", uId);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
}
catch (SqlException ex)
{
throw new Exception(ex.StackTrace + ex.Message);.......
View 1 Replies
Similar Messages:
Feb 15, 2011
I have a class library which has my LINQ doc in it. I added a stored procedure and I get the following in my .dbml.layout :
[Code]....
I include a reference to the dll of the class library to my web project and I get an error about value being returned as int where I am trying to put contents into a datalist or similar.
Code in class that calls this SP :
[Code]....
So I switched code to the following in my dbml.layout document :
[Function(Name="dbo.sp_newsSearch")]public IEnumerable<news_search_result> sp_newsSearch([Parameter(DbType="VarChar(200)")] string searchVal){IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), searchVal);return ((IEnumerable<news_search_result>)(result.ReturnValue));}
And included the following in an external file news_search_result.cs
[Code]....
But now I just get nothing returned. Is this wrong way of calling a SP via LINQ? or have I just put the wrong return type on my LINQ class?
View 2 Replies
Nov 10, 2010
With script below, request to the server always sends empty string (even if value is not emtpty), where the data line is:
data: "{ 'folderName': '" + $(this).val() + "' }"
The html element under investigation is this:
<asp:TextBox id="searcher" runat="server" ClientIDMode="Static" CssClass="classificationFolder" />
Script is:
<script type="text/javascript">
$(document).ready(function () {
$(".classificationFolder").each(function () {
[Code]....
The reason that I select elements by css class selector ($(".classificationFolder")) is that, this control is a user control and used in the same page more than once. That is why I'm not using $("#searcher").
I tested the code In IE8 and Chrome 8.0.552.28 beta. This issue is arising in both of the browsers.
On the other hand, request is sent to the server, client received response successfuly and response is processed on the client.
View 3 Replies
Apr 4, 2011
I define the datasource in my c# code and I have a submit button which takes the value of the radiobuttonlist
asp:RadioButtonList ID="RadioPaidIdList" runat="server" DataValueField ="Label" DataTextField = "Label"
First time i click submit it returns an empty value. And next time i select a radiolist and click submit it returns a proper value.
View 2 Replies
Oct 13, 2010
This is completely frustrating and probably embarrassing as well. A while back I posted a similar question and resolved the issue. [URL]...scope_identity The program has been working ever since, until yesterday when as it turns out SCOPE_IDENTITY() started returning an empty string even though a record is being inserted. I am not sure what has changed since the fateful day.
[Code]...
I am hoping that there is something I am just not seeing here. A lot of the information I have seen thus far indicates that there are problems with SCOPE_IDENTITY() but most of those are related to inserting multiple records. As you can see this should be fairly straight forward. The thing that really has got my goat is that it used to work and now it doesn't. If someone could take a look at the above code and comment on any anomalies it would be great. Also I have heard suggestions for switching to ADO.NET and it is beginning to look a lot more attractive every day. But I have a ways to go before making the switch so it is SqlDataSources for now
View 37 Replies
Jan 29, 2010
I have developed a web application 3 months ago to show facebook users by searching username. To access facebook, I have downloaded facebook dll and got application key, and secret key from facebook. My web application was working fine and displaying records from facebook. yesterday onwards, my application is not working fine. I could not get response when I search by name. I have tested the fql in the facebook testAPI tool online. That time i can get response. but the same fql i used in my appliation but it could not get response from facebook when I search by name. If i search by uid i can get response from facebook. here is my code.
facebook.Components.FacebookService fb = new FacebookService();
fb.ApplicationKey = "bfeefa69afdfe81975f0d6136ace3009";
fb.Secret = "9b672d682e1d8befd06382953fc2615b";
fb.IsDesktopApplication = false;
//the below fql gives response as xml.
//select name, profile_url from user where uid = '1730923544' -I can get response for this fql.
//the below fql does not give response as xml. But it gives empty string.
//the below fql does gives us response as xml when i try in facebook testAPI.
//select name, profile_url from user where name = 'Suresh Rajan' -I couldn't get response for this fql.
string s = fb.fql.query("select name, pic_square, profile_url from user where name = 'Suresh Rajan'");
if (String.IsNullOrEmpty(str1))
Response.Write("Empty Response");
else
Response.Write(str1 + " ");
how to search by name in facebook fql.
View 1 Replies
Feb 11, 2010
I am trying to import data from excel and Reading Excel sheet from asp.net returns empty cell, when the data type is changing from number to text example
Prog
----
2000
4000
6000
AN00 -- reading as empty
BN00 --reading asempty
this is the conncetion string i use with vb.Net
Dim strConn As String = "Provider=Microsoft.Jet.OleDb.4.0;" _
& "data source= '" & FileName & "';" _
& "Extended Properties=Excel 8.0;"
View 3 Replies
Feb 13, 2010
I have a DataTable for which a PrimaryKey constraint has been set to be a combination of an integer column and a datetime column. When I try to 'Find' a row by saying,
dtFunds.Rows.Find(iContainerIndex)
I get a null value. iContainerIndex has been defined as an object array of size 2 with the integer ID and date values in it.
When I set a breakpoint in my code, I see that the very same values are present in the datatable.
If I try to execute, DataTable.Select() method with the integer column filter, I get a result - but returns no result when called with the date column filter.
What am I doing wrong here? The very same DateTime value is present in the datatable.
View 1 Replies
Feb 7, 2011
I am trying to use a SqlDataAdapter to fill a DataTable, which I use as a data source to a DataGrid. The query is fine, at least when I run it manually in SSMSE. When I do the fill operation, the table gets the right columns, but no rows. The most frustrating part of this is that the code is identical (with a different query) on a different page. I cannot post the query, but my initialization code looks like this:
SqlCommand areaDAC = new SqlCommand (areaQuery, connection);
areaDAC.Parameters.Add (new SqlParameter ("@param", System.Data.SqlDbType.NVarChar, 50));
m_areaDataAdapter = new SqlDataAdapter (areaDAC);
Then to use it:
m_areaDataAdapter.SelectCommand.Parameters["@param"].Value = "Filter Val";
DataTable table = new DataTable ();
m_areaDataAdapter.Fill (table);
At this point, table has the right number of columns and no rows. I know the parameters are being added correctly, I know that data exists for the given query.
Update (as provided by Nik in a comment):
[Code]....
View 4 Replies
Jul 16, 2010
[Code]....
returns the error: The parameter 'username' must not be empty.Parameter name: usernameI want to check if a user is logged. If not logged in redirect to loginerror.aspx.
View 9 Replies
Oct 7, 2010
Since I am not using a DataSourceId at the markup I am having to create my own Sorting handler. I found a sample on MSDN but the variable 'dataTable' always returns null why?
[Code]....
and here is how I am feeding the DataGrid:
[Code]....
View 2 Replies
Oct 20, 2010
I'm trying to set up the SSL in my web app, but don't know if i'm doing it right, or if even i'm taking the right steps in the right order.I have a function in a class that returns the secure URL (https://mydomain.com/...aspx) if the current url is not secure (http)
[Code]....
(Though in develop environment It's like "https://localhost:port" + rawUrl)
when the function returns ssl value, if it's not empty, then the master page redirects to the new url... but the browser is not showing it...
View 5 Replies
Oct 5, 2010
Im using "string user = Database.GetMostRecentReply(id).Rows[0][2].ToString();" to get the username from the most recent reply in my forum.
But how do I check if the row is empty? Im using a try catch at the moment, but there must be a better way to do this.
View 2 Replies
Feb 14, 2012
Gridview Sorting is not Working Since Datatable is Empty
Code: Dim dt As DataTable = TryCast(GRDV.DataSource, DataTable)
above code is returning Empty Gridview ..
code is below
Protected Sub GRDV_Sorting(sender As Object, e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles StudentAssignmentgridview.Sorting
'If showImage = False Then
' showImage = True
'End If
[Code] ......
View 1 Replies
Nov 1, 2010
I am trying to populate a gridview using two tables. I also have a strongly typed dataset and used the method on this page: [URL] the problem is that, when i try to use two table the gridview does show up (I checked through debugging that the datatable comes back as empty).
View 2 Replies
Aug 27, 2010
private void FillDetails(string pId, out string Name, out string Address)
[code]....
I have method called Filldetails(),This method uses stored procedure to retrieve information for product name and address based on productid passed from productdetails table.I am working on globalization project.We have this product information for US country but there is no product information for germany country.So dataset is empty for germany.As result I am getting error object reference not set to an instance of the object.
View 3 Replies
Oct 15, 2010
I have in my code a gridview that I redirect to excel, it works fine when I have data in the data set. waht I want is to show column headers when there is no data right now what i get is empty sheet.
View 7 Replies
Feb 24, 2010
I am using asp.net oledb to export information to excel file. I encounter problems when the information to export becomes too big, in this case the code I have given below, the excel file generated becomes an empty spreadsheet. If I changed the loop to 1123 for insertion of the rows. The generated excel file is fine, 1125 rows, and 4 columns shown. A test program in windows form is also working fine regardless of how many rows.
Code has been simplified, "information ..." in the sql insertion command represents 1803 characters.
ExcelObjConn = "Provider=Microsoft.Ace.OLEDB.12.0;" & _
"Data Source=" & fileName & ";Extended Properties=Excel 12.0 XML"
ExcelConnection = New System.Data.OleDb.OleDbConnection(ExcelObjConn)
ExcelConnection.Open()
Try
SqlCommand = "CREATE TABLE ABC ([row1] text, [row2] text, [row3] text, [row4] text)"
ExcelCommand = New OleDb.OleDbCommand(SqlCommand, ExcelConnection)
ExcelCommand.ExecuteNonQuery()
ExcelCommand.Dispose()
For i As Integer = 0 To 1124
SqlCommand = "Insert into ABC ([row1], [row2], [row3], [row4]) Values ('information...', 'information ...', 'information ...', 'information ...')"
ExcelCommand = New OleDb.OleDbCommand(SqlCommand, ExcelConnection)
ExcelCommand.ExecuteNonQuery()
ExcelCommand.Dispose()
Next
Catch ex As Exception
Finally
If ExcelConnection IsNot Nothing Then
ExcelConnection.Close()
ExcelConnection.Dispose()
End If
End Try
I couldn't find a solution to my problem as well. What I did eventually was to run the process using another separate windows service. The code works perfectly fine running from a windows form or service program, but not asp.net, not sure why.
View 1 Replies
Aug 25, 2010
I am new to web service. I am trying to connection to an oracle database with 2 input parameters. The web service works fine in the VS2010 environment but when i publish it on to my local machine IIS or on the test web server I do not get a result set back. I get this:
<?xml version="1.0" encoding="utf-8" ?>
<DataSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:nil="true" xmlns="http://test.INT/" />
View 2 Replies
Mar 11, 2010
I have a ListView control and under ItemTemplate I have following code:
Code:
<asp:Label ID="Label1" runat="server" Text='<% #MatchCategory(dtCategories.Rows[i]["ID"].ToString().Trim(), Eval("CategoryID").ToString()) %>'></asp:Label>
The MatchCategory method just checks if two values are equal and return true or false. Just below this code I am separately printing dtCategories.Rows[i]["ID"].ToString().Trim() and Eval("CategoryID")
acan see matching values but MatchCategory method always returns false.
View 5 Replies
Mar 23, 2011
I am new to webmatix and I do not do much development. I was trying to get some values from a request object and it's probably something very stupid I am doing wrong but really I cannot see what it is. This is the code I am trying to use, but I get no value from any items from the form:
@{
Layout = "_SiteLayout.cshtml";
Page.Title = "test";
if (IsPost)
[Code]....
View 3 Replies
Sep 24, 2010
my gridview row updating events return old values.. edititem templatefield gets its old value on row updation.
My code is as follows :-
[Code]....
View 5 Replies
Mar 22, 2010
I had a page inside a master one the page is like
[Code]....
[Code]....
and my code behind
[Code]....
On debugging I noticed that no values are taken from textbox and in postback the textbox is cleared.
I worked in viewstate stuff and enabled it for the textbox and page, but with no results.
View 8 Replies
Nov 17, 2010
Im dynamically creating several dropdowns onclick of a button... but the dropdown returns null when im trying to get the values on submitting the form... i read tat during postback all dynamically created controls will be lost... s there a way to register the controls... i want to access the item selected in the dropdown .... expecting a positive reply...
View 1 Replies
Jan 30, 2010
For coonverting Linq to DataTable I am using the following Extension Method(Taken from Stackoverflow)
L[code]....
The Extension Method creates XML file.But for null values no element is created in XML file.Say if Commission field is null then commission element is missing in Xml generation.
I want to insert element with empty string for null values (ref type) and (0.00) for decimals and (0) for integers. where do i need to make change?
View 1 Replies