Accessing Value From SqlDataSource

Jan 24, 2007

I have a SqlDataSource that returns a list of companies and their details by ProductID.  It also returns the name of the product associated with the ProductID as the final column (which means it appears for every record returned).  I already have a way of determining how many rows were returned, and use that information in a label to say "Your search has returned x records".
protected void dsGetSuppliersByProduct_Selected(object sender, SqlDataSourceStatusEventArgs e)
    {
        int RecordCount = e.AffectedRows;
        if (RecordCount == 0)
        { lblRecordCount.Text = "<p>No Records found"; }
        else
        {
            if (RecordCount == 1)
            { lblRecordCount.Text = "<p>Your search returned 1 record"; }
            else
            { lblRecordCount.Text = "<p>Your search returned " + RecordCount + " records"; }
        }
        string ProductName;
    }

How can I access the ProductName value so that I can extend the label text to say "Your search has returned x records for <ProductName>" ?

View 1 Replies


ADVERTISEMENT

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

Accessing Data From The SQLDataSource.

Apr 5, 2008

I am using a drap and drop SQLDataSource control.  Everything works like I am wanting it to, but I want to check a value from one of the fields that I have retrieved.  I am lost as how to retreive just the field.  If I have to create another dataset to do the work what is the point of using the drag and drop control?  I would really like to just access the dataset fields as needed.

View 2 Replies View Related

Accessing Data Directly From A SqlDataSource?

Mar 7, 2007

First let me give you a little back ground on me.  I'm very new to the ASP, ASP.NET, Visual Studio, Sql Server, Frameworks....thing.  I am coming over from a PHP/MySql background of over 5 years.  The change over to VBScript and VB has been to tough and I have a basic liking for the Visual Studio 2005 and the ease of putting things together.  However, I have come across something that to me seems like it should be relatively simple, but haven't been able to find the documentation or samples to describe what I'm looking to do.
Rough Need:
1.  Start with a form will a couple labels and a singe textbox to get the lookup date from an user.
2.  Query one table/view based on the users choice of date and select only one field of returned data.(Doing this by itself is not a problem and I can display my results in a Gridview, but this is where it starts getting tricky and the gridviews won't work for me.)
3.  If there is something returned, I need to start a HTML table layout or possibly some form of a Gridview(I don't see how I would use the Gridview) and start a loop, adding the first returned row from this query into the first cell.
4.  Now, based on that same User Date and the returned row value from the previous query, I need to query another Table/view and return another single field, which might return 1 or multiple rows, which I need to start a loop to display unique items in cells under the first on above.
5.  Based on the original User Date and each returned row from the first query, I need to query two other Table/views and get some additional information.  4-5 fields will be returned and be displayed on one row in the number of necessary columns.
6.  This would finish the first row from the first query, so I would need to loop back up to see if there were any further results and continue looping until the get to the last of the results from the first query.
7.  Finally, I would just need to close up the Table/gridview.
The basic results I'm looking for would be similar to the following:
Results for 10/11/2005



Field name 1
Field name 2
Field name 3
Field name 4
Field name 5



First Result from query 11 of 4 results from Query 2, but only 1 unique result

Info from Query 3

Info from Query 3
Info from Query 3
Info from Query 4
Info from Query 4

Info from Query 3
Info from Query 3.
Info from Query 3
Info from Query 4
Info from Query 4

Info from Query 3

Info from Query 3   
 
Info from Query 3
Info from Query 4
Info from Query 4

Info from Query 3
Info from Query 3
Info from Query 3
Info from Query 4
Info from Query 4



Second Result from query 1First result from Query 2 after looping though the first query Second result from Query 2 after looping though the first query

Info from Query 3

Info from Query 3
Info from Query 3
Info from Query 4
Info from Query 4

Info from Query 3
Info from Query 3.
Info from Query 3
Info from Query 4
Info from Query 4

Info from Query 3

Info from Query 3   
 
Info from Query 3
Info from Query 4
Info from Query 4

Info from Query 3
Info from Query 3
Info from Query 3
Info from Query 4
Info from Query 4
It seems me from what I have read and slowly figuring out, is that I should be able to directly access the DataSet returned by four SqlDataSources, one for each of the above querys and then just write my own VB to handle the necessary looping, table format and such.  I can easily add the for SqlDataSources to the page and add a Gridview for each one and get 4 separate chunks of info, but can't see a way with GridViews to intermingle the info like displayed above.
So, if it can be done with Gridviews, then I would love to see how that is done.  But, if someone could explain to me how I access the DataSets directly that I get from the 4 SqlDataSources, then that would be ok too.  I have figured enough out with VB, that I can write the code to do my looping requirements, if I can just access the information I get back.  Thanks for reading all the way through this long post.
 Jack 

View 1 Replies View Related

SQLDATASOURCE ~ ACCESSING DATA PROGRAMATICALLY

May 9, 2007

Can anyone point me in the direction of code that will allow me to acce3ss the data held in an SQLDataSource.
 
The Control is link Selection Staement has been set at run, what I want to do is loop thru any data that is rertrieved, setting oter controls on the page depending on values
 Thanks
 Steve (I have not got much hair left, please help soon)

View 3 Replies View Related

Accessing Data From A Programmatically Created SqlDataSource

Nov 3, 2007

Hi
I think I've programmatically created a SqlDataSource - which is what I want to do; but I can't seem to access details from the source - row 1, column 1, for example????
If Not Page.IsPostBack Then
'Start by determining the connection string valueDim connString As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
'Create a SqlConnection instanceUsing connString
'Specify the SQL query
Const sql As String = "SELECT eventID FROM viewEvents WHERE eventID=17"
'Create a SqlCommand instanceDim myCommand As New Data.SqlClient.SqlCommand(sql, connString)
'Get back a DataSetDim myDataSet As New Data.DataSet
'Create a SqlDataAdapter instanceDim myAdapter As New Data.SqlClient.SqlDataAdapter(myCommand)
myAdapter.Fill(myDataSet)Label1.Text = myAdapter.Tables.Rows(0).Item("eventID").ToString() -??????????????
'Close the connection
connString.Close()
End Using
End IfThanks for any helpRichard
 

View 1 Replies View Related

Programmatically Accessing An SQLDataSource With A SELECT COUNT(*) Query.

Jun 20, 2007

I've found example code of accessing an SQLDataSource and even have it working in my own code - an example would be  Dim datastuff As DataView = CType(srcSoftwareSelected.Select(DataSourceSelectArguments.Empty), DataView)  Dim row As DataRow = datastuff.Table.Rows(0)   Dim installtype As Integer = row("InstallMethod")  Dim install As String = row("Install").ToString  Dim notes As String = row("Notes").ToString The above only works on a single row, of course. If I needed more, I know I can loop it.The query in srcSoftwareSelected is something like "SELECT InstallMethod, Install, Notes FROM Software"My problem lies in trying to access the data in a simliar way when I'm using a SELECT COUNT query. Dim datastuff As DataView = CType(srcSoftwareUsage.Select(DataSourceSelectArguments.Empty), DataView) Dim row As DataRow = datastuff.Table.Rows(0) Dim count As Integer = row("rowcnt") The query here is "SELECT COUNT(*) as rowcnt FROM Software"The variable count is 1 every time I query this, no matter what the actual count is. I know I've got to be accessing the incorrect data member in the 2nd query because a gridview tied to srcSoftwareUsage (the SQLDataSource) always displays the correct value. Where am I going wrong here?  

View 6 Replies View Related

SELECT A Single Row With One SqlDataSource, Then INSERT One Of The Fields Into Another SqlDataSource

Jul 23, 2007

What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.

View 7 Replies View Related

Individual SqlDataSource() Or Common SqlDataSource() ?

Mar 8, 2007

i am using visual web developer 2005 with SQL Express 2005 with VB as the code behindi have one database and three tables in itfor manipulating each table i am using separate SqlDataSource() is it sufficient to use one SqlDataSource() for manipulating all the three tables ? i am manipulating all the tables in the same page only please help me

View 1 Replies View Related

ASP.NET/C# Accessing A SQL DB

Sep 14, 2004

Good Morning,

I am wondering if anyone can help me/ Currently I have created an ASP.NET webform. Usingt the VS.NET C# IDE I have put a SQL connection and DataAdapter on the webform. I have then created a dataset which should hold the contents of a table on a SQL server db.

However when i run the page which just tries to fill the dataset i get the error below. I am running the page via IIS on WinXP Pro SP1 system and SQL Server is located on a Win2003 Svr.

Can anyone help?

Thanks & Regards,

Alan

Server Error in '/Quiz' Application.
--------------------------------------------------------------------------------

SQL Server does not exist or access denied.
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: SQL Server does not exist or access denied.

Source Error:

Line 38: // Put user code to initialize the page here
Line 39:
Line 40: sqlConsumerDataAdapter.Fill(consumerDS11);
Line 41:

Source File: c:inetpubwwwrootquizwebform1.aspx.cs Line: 40

Stack Trace:

[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +484
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
Quiz.WebForm1.Page_Load(Object sender, EventArgs e) in c:inetpubwwwrootquizwebform1.aspx.cs:40
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

View 7 Replies View Related

Accessing URL

Oct 13, 2006

Hi!

I have two assets: a URL that points to an XML file, and a stored procedure that can accept this file as a text variable and store it in a SQL 2005 table.
create procedure [dbo].[insertObjects]
@availabilityXml text
as
DECLARE @xmlHndAdd INT
EXEC sp_xml_prepareDocument @xmlHndAdd OUTPUT, @availabilityXml
TRUNCATE TABLE Objects
INSERT Objects
SELECT *
FROM OPENXML(@xmlHndAdd, '//NewDataSet/Table1', 2)
WITH Objects

Now, I need to find a solution to combine the URL with the proc. Does anyone have any suggestions on how I can pass my URL as a text variable to the procedure? SSIS, vb-script, etc. are welcome!

Thank you!

View 5 Replies View Related

Accessing A DSN Through A Sql Job

Nov 13, 2006

I am trying to execute an SSIS package (which accesses a dbf file through an odbc connection) through a Sql job, but the package log reports an error of "Disk or netowrk error". When I execute the package in the IDE, the package executes fine. When I run the manifest on the DB server, I can execute the package with no errors. But, when I create the job, and try to execute the job, it fails. I thought at first that the user didn't have privileges to the directory that the file existed in, but that isn't the case.

Can anyone shed some light on how to accomplish what I am trying to accomplish? It seems like this would be a common use of SSIS, but I cannot seem to get it to work.

Thanks in advance for any assistance you can provide!

Craig

View 2 Replies View Related

Accessing Two Databases

Sep 16, 2006

Hi, I am developing a small asp.net  application where I read from a readonly omnis database via odbc then dependant on user input write records to a second database.My first idea was to use an odbc connection to Omnis database and write to ms sql database.  There is quite a few queries that need to be made to the Omnis database and I am binding a datagrid to the MS Sql server database.  I was hoping to use stored procedures to update the mssql tables.  So there will be much opening and closing of connections. Should I go down that road or should i think of using an Access database, with linked table to the Omnis database, then only one connection needs to be made.  And I can store my information in the Access database tables. Thanks.

View 3 Replies View Related

Remote Accessing

Dec 10, 2006

Hello,I just uploaded a new SQL database to my hosting server.I am using SQL 2005 and SQL Server Management Studio.How
can I remotely access the SQL database, on my hosting server, to create
or alter tables and queries, using SQL Server Management Studio? Thank You,Miguel

View 2 Replies View Related

Accessing 2nd, 3rd And 4th To Last Records

Apr 7, 2008

Hey All
I wish to display the 3rd and 4th to last records of a table on a page. Is there anyway of doing this? I can access the last records by using Count and TOP 1 but i find that count - 1 as the ID to select can be errornous if records are removed from the table. I also tried using ORBER BY followed by LIMIT but kept getting an error in order by clause message.
Any help would be greatly appreciated
Thanks and Regards
 Drew

View 6 Replies View Related

Error Accessing T-SQL UDF From CLR UDF

Jun 11, 2008

Hi all,
I am experiencing the following error when I try to access a T-SQL UDF from within a SQL statement that I execute from a CLR UDF.Msg 6522, Level 16, State 1, Line 2
A .NET Framework error occurred during execution of user-defined routine or aggregate "HelloWorldCLR":
System.Data.SqlClient.SqlException: This statement has attempted to access data whose access is restricted by the assembly.
System.Data.SqlClient.SqlException:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnectionSmi.EventSink.DispatchMessages(Boolean ignoreNonFatalMessages)
at Microsoft.SqlServer.Server.SmiEventSink_Default.DispatchMessages(Boolean ignoreNonFatalMessages)
at Microsoft.SqlServer.Server.SmiEventSink_Default.DispatchMessages(Boolean ignoreNonFatalMessages)
at System.Data.SqlClient.SqlDataReaderSmi.InternalNextResult(Boolean ignoreNonFatalMessages)
at System.Data.SqlClient.SqlDataReaderSmi.NextResult()
at System.Data.SqlClient.SqlCommand.RunExecuteReaderSmi(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteScalar()
at UserDefinedFunctions.HelloWorldCLR()I have tried the SQL BOL and Google with no luck.
Here is the sample code I am using to produce this error:
HelloWorldUDF.sqlIF OBJECT_ID (N'dbo.HelloWorldUDF') IS NOT NULL
DROP FUNCTION dbo.HelloWorldUDF
GO

CREATE FUNCTION dbo.HelloWorldUDF() RETURNS varchar(100)
AS
BEGIN
RETURN 'Hello World'

END
GOHelloWorldCLR.cs using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;

public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction( DataAccess = DataAccessKind.Read )]
public static SqlString HelloWorldCLR()
{
using ( SqlConnection conn = new SqlConnection( "context connection=true" ) )
{
conn.Open();

SqlCommand command = new SqlCommand( "SELECT dbo.HelloWorldUDF()", conn );
return new SqlString( command.ExecuteScalar().ToString() );
}
}
};

Test query:  select dbo.HelloWorldUDF()
select dbo.HelloWorldCLR()  Could some one please confirm that this should be possible or not? Thanks! Joe.

View 3 Replies View Related

Accessing MS SQL DB On Own Server?

Dec 10, 2004

Hi

If my site is hosted with an external company web host can I use ASP.NET pages to connect to a MS SQL DB that is on my company's internal server if I had MS SQL installed on it?

My company's server is always on and always connected to the internet.

I have access to my company's server if I need to set anything up on it for this to happen.

There will not be any kind of overload as the site is not accessed constantly.

Also, would this cause any kind of security leak? If so how would I go about plugging this hole?

Our server does have confidential info on it.

Cheers

kefi2927

View 1 Replies View Related

Accessing DTS From Another Machine

Oct 11, 2000

I am trying to open some DTS packages from another machine, I see the list but when I try to open one and I get the error: The Parameter is incorrect

I have look at permissions and everything looks good. (I can view about 2 out of 20 packages all packages have the same owner.)

Any would be great.

Thanks
Jacqi

View 1 Replies View Related

Accessing SQL From A Web Server Using ASP

Jul 9, 1999

I'm using OLEDB in my ASP code to connect to the SQL database. When I execute the page I got an error saying "438, Microsoft VBScript runtime error, Object doesn't support this property or method"
Anybody knows what this is in reference to.
I tested the same site in another server where IIS and SQL are in the same box and it's working fine.

Thanks for any input in this......

View 1 Replies View Related

Accessing SQL Server With VB6

Jul 19, 2004

I need to write a VB app (VB6) to access and manipulate data within a MS SQL Sever 2000 database. I have experience doing this with MS Access. Is it much different/more difficult to do this with SQL Server?

Thanks

View 5 Replies View Related

Accessing SQL Server Using C++

Nov 25, 2004

What is the easiest way to start executing SQL statements onto a SQL Server 2000 using C++ ?????

Are there any libraries or something I could use ?

View 2 Replies View Related

Accessing From Linux

Nov 24, 2005

Hi All,


Can I connect to the MS SQL database from the Redhat Linux 9.
Is there MS SQL client or database driver on linux available. I wanted to use the data from the MS SQL database in the C++ program running on Linux.

Thanks in advance,

torpedo

View 2 Replies View Related

Accessing The Transaction Log

Jan 6, 2006

Dear All,

Can someone let me know how I can have a look at the transaction log in SQL server. I'd like to find out what INSERT, UPDATE, DELETE commands have been executed on a table today, yesterday etc.

Can I see this easily?

View 8 Replies View Related

Accessing Two Databases At Once

Apr 12, 2006

I'm new to databases as you probably can tell. A friend sent me three data bases, which in my mind should have been one database with all the tables included, but he didn't. So my question is, can you pull info from two databases in the same query?

I write the query acessing one database and the result chart must depend on a where predicate based on accessing tables in another database. If this isn't possible, how do I get the tables I need together, that presently reside in differing databases?

Thanks for the help in advance.

Milfredo

View 8 Replies View Related

Accessing MySQL From .NET

Jan 5, 2004

Hello all,

We are planning to migrate an application written in Perl + mySQL to .NET + MS-SQL Server. The test machine now has SQL Server running. During the development phase in .NET, we would want to access the mySQL database which is being updated at real time, from the Windows box. This is how I think it has to be done:

1. Use DTS to migrate data from mySQL. Does DTS take care of migrating schema and the difference in data types between the mySQL and MS-SQL? Is there any 3rd party software out there that takes care of the migration without any manual labor?

2. Synchronize the data between 2 DBs by creating some kind of a batch job? If so, whats the best way of doing this?

Instead, is it easier to access the live mySQL database on the Linux box from the .NET code and move the DB only after development in the new environment is completed?

Any help/ideas is greatly appreciated.

TIA

View 2 Replies View Related

Accessing Problem

Mar 29, 2004

I want two things:

-Let the windows account be the login on the SQL server. This is not a problem.


1.But I also want to use the windows login as authentication method for the webpage. The users have to explicitly log-in.
2.Is it a problem to retrieve all users within a windows domain?

I’m using .net 2003.

View 2 Replies View Related

Accessing Second Record Set

May 7, 2004

hello all,

i had two stored procedures,where the 1st SP is calling 2nd SP(which returns 2 record sets).
how can i access the second recordset from the 1st SP

it would a great help if anyone help me out!!

thanx in advance,
ravi.

View 2 Replies View Related

Accessing SQL Through Another Computer

Apr 29, 2008

Hello, me and my friend has set up an SQL, I am wondering if it is possible to access the SQL server from my computer when hosted on his.

thanks

View 1 Replies View Related

Accessing Another DB Through A View

Mar 12, 2008

I have to troubleshoot a problem with a complex sproc that is running against a number of views that select entire tables from another "production" database. The problem we are having is that while the views should be read-only, there are no transactions, and no locking, the application's process on SQL Server is blocking anyone else who tries to write data. I'm wondering if this method of using a view as a proxy to another DB is effecting the block. The reason for doing this was to improve performance by offloading the production DB, but since it's the same instance of SQL Server, does it really matter? THX for your advice.

Jerry O'Brien

View 1 Replies View Related

Accessing Row In ForEach

Dec 16, 2007

Hello everybody.
I'm having a problem:
As the result of Dataflow task I get a recordset with about 50 columns in it. Now I need to loop through each row in the dataset and make some manipulations with the data in all 50 columns in a single script task. So I need 'em as separate variables.
Ofcourse I can make a For Each Loop container with ADO enumerator, and map each column to specific variable. But that's not a very good thing, because if the format changes, i will have to remap everything again (takes a lot of time to remap 50 values)

So is it possible:
1. To map using not index of columns, but there names?
2. To pass actual row into the script task?

View 7 Replies View Related

Accessing Records

Apr 6, 2006

Hi

Would anyone be able to advise me on the best way in which i am able to display the information from a Search in sqlce database and allow the results be displayed in a specified location.

An example is in my program there is a list of id which the user can search. They search for a record by id so only one record will return. I would like this information to then be displayed in the textboxes which are on the screen.

Any problems understanding what i am trying to do please ask. Any help would be appreciated

Thanks

View 3 Replies View Related

Accessing FTP Site

May 15, 2008



Hi,

I am trying access a FTP site present from a different server (remote work station). I am getting "The page cannot be displayed" error. I am able to access from my local machine.

Please help me solving this.

Regards,
Sriram.

View 3 Replies View Related

Accessing SQL Server From Asp.NET

Nov 6, 2007

Greetings. I am curently having problems with authorizations while attempting to connect to SQL Server with an Asp.NET web application. I will try to explain my problem as clearly as possible.


I am developing an Asp.NET web application with Visual Studio to connect and view a database on a remote SQL Server. In my Web.config file, I have added the line


<identity impersonate = "true"/>


In my IIS security options, I have disabled the annonymous authentication and enabled the Windows mode authentication instead. When accessing the database from my computer, by compiling and debugging my web application in Visual Studio, everything works wonder. When I try to use the web application from a remote computer using the IP address or from my own computer using localhost in the URL, it asks me for my Windows username and password, which I provide, and then refuses any further access, saying I don't have permission to even connect to the server.

How can I go around this and allow my users to connect to the server from a remote computer? My machine is running Windows XP SP2 and the server is running Windows Server 2003.

Thank you in advance for any help you may provide,

Marie

View 3 Replies View Related







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