How To Retrieve And Display Data From SQL-server?
Feb 15, 2008
Hello,
I need to retrieve data from a SQL-server table using a stored procedure. I want to retrieve the values from the table and add them to labels on a form. What is the easiest way to do this? Is dataset the solution?
I appreciate any help!
string sCN = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlConnection2 = new SqlConnection(sCN);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.AddWithValue("@userID", userID);
Int32 rowsAffected;
cmd.CommandText = "get_user"; //Stored procedure to get user data. Takes UserID as parameter
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = sqlConnection2;
sqlConnection2.Open();
rowsAffected = cmd.ExecuteNonQuery();
sqlConnection2.Close();
View 20 Replies
ADVERTISEMENT
Jan 21, 2008
Below is code for inserting data into the database that I know works, so I thought if I replace "Insert" with "Select" I could retrieve a specific row from my database and present it in a label or text box but nothing happened. How can I retrieve a row or rows from a database using vb code and display it in a textbox? I'm using visual web developer 2008 which is similar to 2005.
Thank you.
Dim UserDatasource As New SqlDataSourceUserDatasource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
UserDatasource.InsertCommandType = SqlDataSourceCommandType.Text
UserDatasource.InsertCommand = "insert into table1 (Username, comments, points,totalpoints, ipaddress, datatimestamp) values (@Username, @comments, @points,@totalpoints, @ipaddress, @datatimestamp)"
UserDatasource.InsertParameters.Add("username", Context.User.Identity.Name)
UserDatasource.InsertParameters.Add("comments", txtSearch.Text)UserDatasource.InsertParameters.Add("points", points)
UserDatasource.InsertParameters.Add("ipaddress", Request.UserHostAddress)UserDatasource.InsertParameters.Add("datatimestamp", DateTime.Now())
Dim rowaffected As Integer = 0
Try
rowaffected = UserDatasource.Insert()MsgBox("Thanks for the post", MsgBoxStyle.OkOnly, "Post Executed")
txtSearch.Text = ""Catch ex As Exception
MsgBox("Please sign in or sign up to post comment", MsgBoxStyle.OkOnly, "Login Error")
End Try
View 2 Replies
View Related
Jan 19, 2012
I am using Query Writer (should be SQL 2005) and have included the following code.
The end result: -should retrieve columns and display the count for two different data sources that were added by personnel in a specific department.
Problem: results are returned but not accurate. The code below works just fine and returns the results for all spot buy orders added by personnel in the sales department. However, I want to add a column in the same report that also counts blanket orders from the exact same table added by personnel in the sales department. The database uses views (v) in lieu of dbo.
Parameters:
@Add_Date_From SMALLDATETIME='',
@Add_Date_To SMALLDATETIME='',
@Last_name VARCHAR(50)='',
@First_Name VARCHAR(50)=''
Query:
SELECT
T1.Last_name,
T1.First_name,
T2.Position,
T3.Add_date,
COUNT(T4.PO_Type) AS 'Spot Buy Added'
[Code] ....
If I substitute COUNT(T4.PO_Type) AS 'Spot Buy Added' with COUNT(T4.PO_Type) AS 'Blanket Added' I also get accurate results for the blanket order. IE separately they work just fine. If I try to combine the two that is where the trouble begins.
What am I doing incorrectly when I try to add the criteria/code for the additional column to count the blanket orders?
View 9 Replies
View Related
Jul 6, 2006
Ok, the problem is that , i have a field called "Attach" in sql of type image, when selecting it , the field is getting data of type BYTE(). which am being unable to display them on an Image on the panel.
using the following vb.net code:
'Dim sel2 As String
'Dim myCom As SqlCommand
'Dim conn As New SqlConnection
'Dim drr As SqlDataReader
'Dim image As System.Drawing.Image
'sel2 = "select * from attach where att_desc = '" & DropDownList1.SelectedItem().Text & "' and doc_code = " & w_doc_code & " and subcode = " & w_doc_subcode & " and doc_num= " & w_doc_num & " "
'conn.ConnectionString = ("server=developer01;uid=sa;password=aims;database=DVPSOC;timeout=45")
'myCom = New SqlCommand(sel2, conn)
'conn.Open()
'drr = myCom.ExecuteReader()
'If drr.Read Then
' Me.ImageMap1.ImageUrl = drr.Item("attach")
'End If
'conn.Close()
Am getting an exeption on the following line Me.ImageMap1.ImageUrl = drr.Item("attach")
saying: Conversion from type 'Byte()' to type 'String' is not valid.
knowing that i tried converting using ToString but it's not getting any output then.
thanks for your help.
View 4 Replies
View Related
Feb 25, 2006
How would I do if I want to make a query that returns an image, which in turn should be displayed on a webpage?
View 2 Replies
View Related
Feb 9, 2006
Hi Guys,
I have a sql procedure that returns the following result when I execute it in query builder:
CountE ProjStatus
6 In Progress
3 Complete
4 On Hold
The stored procedure is as follow:
SELECT COUNT(*) AS countE, ProjStatusFROM PROJ_ProjectsGROUP BY ProjStatus
This is the result I want but when I try to output the result on my asp.net page I get the following error:
DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name Count.
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.Web.HttpException: DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name Count.Source Error:
Line 271: </asp:TemplateColumn>
Line 272: <asp:TemplateColumn>
Line 273: <itemtemplate> <%# DataBinder.Eval(Container.DataItem, "Count" )%> </itemtemplate>
Line 274: </asp:TemplateColumn>
Line 275: </columns>
My asp.net page is as follows:
<script runat="server">
Dim myCommandPS As New SqlCommand("PROJ_GetProjStatus")
' Mark the Command as a SPROC
myCommandPS.CommandType = CommandType.StoredProcedure
Dim num as integer
num = CInt(myCommand.ExecuteScalar)
'Set the datagrid's datasource to the DataSet and databind
Dim myAdapterPS As New SqlDataAdapter(myCommandPS)
Dim dsPS As New DataSet()
myAdapter.Fill(dsPS)
dgProjSumm.DataSource = dsPS
dgProjSumm.DataBind()
myConnection.Close()
</script>
<asp:datagrid id="dgProjSumm" runat="server"
BorderWidth="0"
Cellpadding="4"
Cellspacing="0"
Width="100%"
Font-Names="Verdana,Arial,Helvetica; font-size: xx-small"
Font-Size="xx-small"
AutoGenerateColumns="false">
<columns>
<asp:TemplateColumn HeaderText="Project Summary" HeaderStyle-Font-Bold="true" >
<itemtemplate> <%# BgColor(DataBinder.Eval(Container.DataItem, "ProjStatus" ))%> </itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<itemtemplate> <%# DataBinder.Eval(Container.DataItem, "Count" )%> </itemtemplate>
</asp:TemplateColumn>
</columns>
</asp:DataGrid>
Please help if you can Im havin real trouble here.
Cheers
View 3 Replies
View Related
May 15, 2007
Hi All,
I am not sure whether this is the right place to post this question. But I am unable to figure out what is the best solution to retrieve and display an image in a html file(stored in varbinary(max) column). I have a list of images in the file and I am supposed to display them. Can anybody please let me know what is the best way to do this?
Thanks a lot!!
View 1 Replies
View Related
Mar 19, 2007
Last night I face performace problems in web site. I got like 100 000 users and site fails because of sql-connections.
Currently I'm making a new connection for every query, and my code looks like this:Public Shared Function executeQueryReturnDataset(ByVal strsql As String) As DataSet
Dim sqlConnection As New SqlConnection(Connstr)
Dim sqlCommand As New SqlCommand(strsql, sqlConnection)
Dim sqlDataSet As New DataSet
Try
sqlConnection.Open()
Dim myDataAdapter As New SqlDataAdapter
myDataAdapter.SelectCommand = sqlCommand
myDataAdapter.Fill(sqlDataSet)
Catch e As Exception
Console.Write(e.ToString())
Finally
sqlConnection.Close()
End Try
Return sqlDataSet
End Function I was wondering would it be better to save an instance from connection object to memory and use that same connection for all querys?
View 4 Replies
View Related
Mar 14, 2006
Let us suppose that there are 900 rows in One table, and that table contains neither primary key, nor Identity column.
How can I retrieve all the roows from 201 to 250?(like the middle limits)
In oracle there is a property called RowID, but is there any such item in SQL server?
View 1 Replies
View Related
Apr 30, 2015
I would like to display a portion of report where there is data or no data
There is data subreport  display  Â
   Product Name Latex Gloves Â
   Product ID   Â
xxxx5678
 There NO data in the subReport
Â
  Product Name             Â
  Product ID  Â
View 3 Replies
View Related
Nov 25, 2005
Hello,
Im using Visual Studio 2005 to code ASP.NET
How to query my MS SQL SERVER 2000 to retrieve data from my DataBase?
Ive tried some tutorials, but i kept giving me errorsCan you put a simple source code to retrieve something like "select userID, Name, Age from Users"
Thank you,
View 2 Replies
View Related
Apr 14, 2008
I am developing a commercial solution for scheduling problems, using different databases. Several of our clients don't have a database server installed in their systems networks, so we thought we would simply use SQL Server Express as a no-cost solution. However, I have come across a MAJOR difficulty:
When I try to log on using SQL Server Authentication (for example, name: "sa" pass: "sa") instead of Windows Authentication, I am simply unable to view any data that does not come directly from a table! No data from queries(!), no data from stored procedures(!!), no data from functions(!!!), only from tables!!!!
And it's not like the queries don't return a dataset, because they do, for a user logged on using Windows Authentication!
And this is not 'simply' a problem of remotely connecting to SQL Server Express, this is also true locally!
There is nothing wrong with my own system, this problem occurs on at least four different windows platforms, vista included. And it is not related to our program, I am having the same difficulty with the Management Studio Express.
I have tried to use several different users, each with different permissions and roles, to no avail.
This is truly a frustrating problem.
It can be solved in one of two ways:
1. Get a non-windows-authenticated user to see the data (get more than 0 rows in the dataset).
2. Manage to log on remotely using Windows authentication.
I am unable to do either one of those, and not for lack of trying. I have been at this for the past week without results.
PLEASE, PLEASE, PLEASE, Can anyone HELP?!?!?!?
View 5 Replies
View Related
May 2, 2006
The project I'm currently working on involves combining data from one SQL Server 2000 databases and XML returned from a web service into a 3rd SQL Server 2000 database.
This process must be scheduled to happen once a day. If it weren't for the Web Service, I'd say that this is a no-brainer and I'd use DTS. However, I'm not sure if I can even access a Web Service with DTS. Has anyone done this or have any tips?
View 1 Replies
View Related
Jun 16, 2001
I'm writing VB 6.0 codes to retrieve data from SQL Server 7.0. if the sql code is embedded in VB, everything works fine. But when I tried to use stored procedure, one error called "invalid object name 'author'" occurs. author is a table in my database and obviously is in the database. what's wrong?
appreciate for any suggestion!
...mike
View 1 Replies
View Related
Jun 14, 2007
Hi,
In SSRS 2005, I have an assembly(dll) which is included in a report in order to retrieve data ( OdbcConnection) from database as special condition while the runtime of report. This assembly works FINE in the preview of VS development tools. But it is NOT working when deploying to server, it ONLY returns default value instead of database's value.
Anyone knows how to solve it ? Many Many thanks
View 2 Replies
View Related
May 12, 2015
I know how to use Linked server query to retrieve data from two different sql on premise instances.I would like to try the same on sql server instances hosted on azure.When I connect to sql instance, I don't see ServerOBjects->Linked server. I just see Database and security.Is this possible on sql azure, if so how can we achieve it
View 4 Replies
View Related
Oct 5, 2007
Hi,
I am getting an error
'Server: Msg 7416, Level 16, State 2, Line 1
Access to the remote server is denied because no login-mapping exists'
when i run the below code,
SELECT a.* from
OPENROWSET('SQLOLEDB',
'Data Source=SA3KNX;
Integrated Security=SSPI;
Initial Catalog=[Mis Mart];
Persist Security Info=False;
Initial Catalog=Mis Mart;',
'select * from [Mis Mart].dbo.Dim_Cus') as a
Can you please help resolve this. The server SA3KNX uses windows authentication and I run this code in another serer 'SEBDTD3' which uses SQL server authentication. How can i retrieve data from a server that uses windows authentication.
Regards,
Sharan.
View 18 Replies
View Related
Jul 26, 2007
Hi everyone,
we have some reference tables in in a specific database. that other applications need to have access to them. Is it possible to create a view in the application's database to retrive data from ref database while users just have access to the application Database not the view's underlying tables?
Thanks
View 1 Replies
View Related
Apr 5, 2007
is it possible to make a custom query to fetch and update data from sql server 2005 in SharePoint designer
i make a new data source library and use a custom query to get data but don€™t know how to configure update custom command
can any buddy help me out
View 1 Replies
View Related
Dec 12, 2013
Trying to get the PSI Outcome, Expected, and PSIIndex every month whether it has data or not. Created a CTE and left outer joined with PSI table, but it's still not pulling every month for every PSIKey.
Table schematics
di.DivisionRegion,int
P.PSIKey,int
P.PSIOutcome,int
P.PSIExpected,int
[Code] .....
View 2 Replies
View Related
Apr 19, 2008
but i am able to login to the same remote sql server through SQL server managment studio express using the details i am using in the connection string in the "test.aspx" page. ERROR:An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)When this page is run, i want all the user's UserName and Password to be dispalyed.However, i am getting the above mentioned error.what could be the problem? This is the code i am using in my test.aspx page to connect to "Login" table in my database. 1 Imports System.Data2 Imports System.Data.SqlClient3
4 Private Sub GetAllTheComments()5
6 Dim MyConnection As SqlConnection7
8 Dim MyCommand As SqlDataAdapter9
10 MyConnection = New SqlConnection("server=XXX.X.XXX.X;uid=X;pwd=X;database=X")11
12 MyCommand = New SqlDataAdapter("select UserName, Password from Login", MyConnection)13
14 ds = New DataSet15
16 MyCommand.Fill(ds)17
18 DataList1.DataSource = ds19
20 DataList1.DataBind()21
22 End Sub
View 1 Replies
View Related
Jan 29, 2014
I want to display data in block. Below is the Create,Insert Script and format of desired output.
CREATE TABLE [dbo].[Test_AA](
[CounterpartID] [varchar](2000) NULL,
[CounterpartName] [varchar](2000) NULL,
[SATName] [varchar](2000) NULL,
[NameOfBO] [varchar](2000) NULL,
[Code] ....
Result Should be like This :
ID:17388
Name:Scottie Berwick
SATName:Scottie Berwick
NameOfBO:
SATAccountNumber:
[Code] ....
View 4 Replies
View Related
Aug 10, 2015
I need to display all the dates within a range even with no data
For example right now my query get the records with the range say...
The range is 7/1/15 thru 7/7/15
I Get...
Joe 7/1/15 xxx
Joe 7/3/15 ccc
Joe 7/5/15 xxx
I want...
Joe 7/1/15 xxx
Joe 7/2/15
Joe 7/3/15 ccc
Joe 7/4/15
Joe 7/5/15 xxx
Joe 7/6/15
Joe 7/7/15
View 9 Replies
View Related
Sep 17, 2007
Hi guys,
When I thought everything is okay with this script, I got a new problem...
I have a VBA's script from Excel 2003 that builds sql script and retrieves data from SQL SERVER 2000.
in order to make the sql running, I need to use a multi - batch processing, to pass and execute every command line once a time.
Up to here, I am using a test case with Account number = '123456' and getting the desire results.
The code below is running okay with the test case, but when changing the account number (mark as yellow in the code) to include all the accounts (or just one other account), I am getting the following ERROR:
run - time error '-2147217871 (80040e31)' - [Microsoft] [ODBC SQL Server Driver] time out expired.
Now, if I take the same code, with the condition that generates the ERROR, and try it into SQL Server, I get the results without errors.
Thanks in advance,
Aldo.
Below the code:
Code Snippet
Function QuerySalesAging()
'--------------------------------------------------------------
'MUST !!! References: Microsoft ActiveX Data Object 2.1 Library
'--------------------------------------------------------------
Dim ConnString As New ADODB.Connection
Dim RecordSet As New ADODB.RecordSet
'Setting Connection String
Driver = "{SQL Server}"
ServerName = "SERVER"
DB_Name = CompanyName
ConnString = "Driver=" & Driver & ";" & "Server=" & ServerName & ";" _
& "Database=" & DB_Name & ";" & "Uid=" & SQLLoginName & ";" & "Pwd=" & SQLPassword & ";"
'Report Criterias
Criteria05 = " AND " & "Accounts.ACCOUNTKEY Between " & AccountKeyAsRange
' -- ==> With AccountKeyAsRange = '123456' AND '123456' it works okay.
' -- ==> With any other value, in example AccountKeyAsRange = '123456' AND '9999999999' it get's ERROR.
CmdLine01 = " USE " & CompanyName
' Check and drop temporary table
TemporaryTableName = "CTE" ' The table is a regular one
CmdLine02 = " if object_id('" & TemporaryTableName & "') is not null exec('DROP TABLE " & TemporaryTableName & "') "
CmdLine03 = " SELECT ..."
CmdLine03 = CmdLine03 & " INTO " & TemporaryTableName
CmdLine03 = CmdLine03 & " FROM ..."
CmdLine03 = CmdLine03 & " WHERE " & "(" & Replace(Criteria05, "AND", "") & ")"
CmdLine03 = CmdLine03 & " ORDER BY ..."
CmdLine04 = CmdLine04 & " ALTER TABLE " & TemporaryTableName ...
CmdLine05 = CmdLine05 & " UPDATE " & TemporaryTableName ...
CmdLine06 = CmdLine06 & " SELECT ..."
CmdLine06 = CmdLine06 & " FROM ..."
ConnString.Open
ConnString.Execute CmdLine01
ConnString.Execute CmdLine02
RecordSet.Open CmdLine01, ConnString
RecordSet.Open CmdLine02, ConnString
RecordSet.Open CmdLine03, ConnString
RecordSet.Open CmdLine04, ConnString
RecordSet.Open CmdLine05, ConnString
RecordSet.Open CmdLine06, ConnString
ConnString.Execute CmdLine01
ConnString.Execute CmdLine02 ' The debbuger stops here:" if object_id('CTE') is not null exec('DROP TABLE CTE') "
ConnString.Execute CmdLine03
ConnString.Execute CmdLine04
ConnString.Execute CmdLine05
ConnString.Execute CmdLine06
ConnString.Execute CmdLine02
'Retrieve Field titles
For ColNr = 1 To RecordSet.Fields.Count
ActiveSheet.Cells(1, ColNr).Value = RecordSet.Fields(ColNr - 1).Name
Next
ActiveSheet.Cells(2, 1).CopyFromRecordset RecordSet
'Cleanup & Close ADO objects
ConnString.Execute "USE master"
ConnString.Close
Set RecordSet = Nothing
Set ConnString = Nothing
End Function
View 1 Replies
View Related
Sep 9, 2015
i want to show data Party Name and Time interval wise. here is my table from where i will fetch data. so pasting table data here.
Call start Call duration Ring duration Direction Is_Internal Continuation Party1Name Park_Time
------------------------- ---------------- ------------- --------- ----------- ------------ --------------- -----------
2015/06/08 08:06:08 00:02:28 2 I 0 0 Emily 0
2015/06/08 08:16:38 00:00:21 0 I 0 1 Line 2.0 0
2015/06/08 08:16:38 00:04:13 5 I 0 0 Jen 0
[code]...
now i am not being able to cross join this CTE with my table to get data party name wise and time interval wise. say for if no data exist for a specific time interval then it will show 0 but each party name should repeat for time interval 9:00:00 - 9:30:00 upto 17:30:00. i like to add what filter need to apply to get data for incoming, outgoing, call transfer and miss call.
For Incoming data calculation
where direction='I' and
Is_Internal=0 and continuation=0 and
RIGHT(convert(varchar,[call duration]),8)<> '00:00:00'
For outgoing data calculation
[code]...
View 3 Replies
View Related
Apr 11, 2007
I'm trying to figure this out
I have a store procedure that return the userId if a user exists in my table, return 0 otherwise
------------------------------------------------------------------------
Create Procedure spUpdatePasswordByUserId
@userName varchar(20),
@password varchar(20)
AS
Begin
Declare @userId int
Select @userId = (Select userId from userInfo Where userName = @userName and password = @password)
if (@userId > 0)
return @userId
else
return 0
------------------------------------------------------------------
I create a function called UpdatePasswordByUserId in my dataset with the above stored procedure that returns a scalar value. When I preview the data from the table adapter in my dataset, it spits out the right value.
But when I call this UpdatepasswordByUserId from an asp.net page, it returns null/blank/0
passport.UserInfoTableAdapters oUserInfo = new UserInfoTableAdapters();
Response.Write("userId: " + oUserInfo.UpdatePasswordByUserId(txtUserName.text, txtPassword.text) );
Do you guys have any idea why?
View 6 Replies
View Related
May 8, 2008
Good day., please help me,in a formview control, i set it in Insert Mode, so it should display info from table 1 but when i click on the insert button, it will insert it in table 2.btw, table 1 and table 2 are in the same database?? how about if they are not in the same database?how?please help me,Thanks.,SALAMAT PO.,
View 3 Replies
View Related
Oct 24, 2007
Hey All,
I am developing a data acquistion system which monitors the amount of energy that a user consumes in different parts of a house and displays the information in real time on their computer screen. I am collecting the data through tranducers attached to the circuit breakers in the breaker box and sending the data to analog-to-digital converter channels in a MCU. I am retrieving the data from the serial port and storing it to a text file. Each line of data in the text file represents three fields which are separated by commas. I will be reading data from multiple data collection boxes so the first field is the unit number, the second fied represents the analog-to-digital converter channel number from each unit, and the third field is the data that is collected from the ATD channel. I am trying to use SSE to retrieve the data from the text file, and parse each line of data into individual columns in a databse. Then I want to be able to extract the data associated with a particular ATD channel number from the databse and display it in the appropriate text field on a windows form.
I've got the MCU programmed. I have no problem collecting the data from the serial port, and I can do the visual basic programming okay. I have absolutely no clue how to read the data into the database, continuosly read new values into the databse, and then access the stored data to update the text fields on the form. Please help if you can, I've been working on this specific problem for a couple of weeks and I'm not making any progress. Thanks.
View 3 Replies
View Related
Jul 17, 2007
Can someone please tell me how to retrieve/query the list of fields from an entity of a report data model that has been published on the reporting server programmatically ?
I am trying to upload a report data model to the reporting server and planning to use that model as the data source and consume it through our existing web application?
Thank you ,
Rashid A. Khan
View 1 Replies
View Related
Oct 24, 2007
Hey All,
I am developing a data acquistion system which monitors the amount of energy that a user consumes in different parts of a house and displays the information in real time on their computer screen. I am collecting the data through tranducers attached to the circuit breakers in the breaker box and sending the data to analog-to-digital converter channels in a MCU. I am retrieving the data from the serial port and storing it to a text file. Each line of data in the text file represents three fields which are separated by commas. I will be reading data from multiple data collection boxes so the first field is the unit number, the second fied represents the analog-to-digital converter channel number from each unit, and the third field is the data that is collected from the ATD channel. I am trying to use SSE to retrieve the data from the text file, and parse each line of data into individual columns in a databse. Then I want to be able to extract the data associated with a particular ATD channel number from the databse and display it in the appropriate text field on a windows form.
I've got the MCU programmed. I have no problem collecting the data from the serial port, and I can do the visual basic programming okay. I have absolutely no clue how to read the data into the database, continuosly read new values into the databse, and then access the stored data to update the text fields on the form. Please help if you can, I've been working on this specific problem for a couple of weeks and I'm not making any progress. Thanks.
View 1 Replies
View Related
Oct 10, 2007
I have nine type of buttons,
EnrollAmtBTM
PlacAmtBTM and so on, I also have a SQL setver view V_Payment_Amount_List from here i need to display the data on the button
this is the select value to display when i choose the agency list and the amount corresponding to that agency_ID is displayed here the agency_ID is fetched from the SQL CONDITION
THIS IS WHERE I GET FETCH AGENCY DATA WHEN SELECTED i.e SQL CONDITIONprotected void CollectAgencyInformation()
{
WebLibraryClass ConnectionFinanceDB;ConnectionFinanceDB = new WebLibraryClass();
string SQLCONDITION = "";string RUN_SQLCONDITION = "";
SessionValues ValueSelected = null;int CollectionCount = 0;if (Session[Session_UserSPersonalData] == null)
{ValueSelected = new SessionValues();
Session.Add(Session_UserSPersonalData, ValueSelected);
}
else
{
ValueSelected = (SessionValues)(Session[Session_UserSPersonalData]);
}ProcPaymBTM.Visible = false;PaymenLstBTN.Visible = false;
Dataviewlisting.ActiveViewIndex = 0;TreeNode SelectedNode = new TreeNode();
SelectedNode = AgencyTree.SelectedNode;
SelectedAgency = SelectedNode.Value.ToString();
Agencytxt.Text = SelectedAgency;
Agencytxt2.Text = SelectedAgency;
Agencytxt3.Text = SelectedAgency;DbDataReader CollectingDataSelected = null;
try
{CollectingDataSelected = ConnectionFinanceDB.CollectedFinaceData("SELECT DISTINCT AGENCY_ID FROM dbo.AIMS_AGENCY where Program = '" + SelectedAgency + "'");
}
catch
{
}DataTable TableSet = new DataTable();
TableSet.Load(CollectingDataSelected, LoadOption.OverwriteChanges);int IndexingValues = 0;foreach (DataRow DataCollectedRow in TableSet.Rows)
{if (IndexingValues == 0)
{SQLCONDITION = "where (Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'";
}
else
{SQLCONDITION = SQLCONDITION + " OR Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'";
}
IndexingValues += 1;
}SQLCONDITION = SQLCONDITION + ")";
ConnectionFinanceDB.DisconnectToDatabase();if (Dataviewlisting.ActiveViewIndex == 0)
{
Dataviewlisting.ActiveViewIndex += 1;
}
else
{
Dataviewlisting.ActiveViewIndex = 0;
}
SelectedAgency = SQLCONDITION;
ValueSelected.CONDITION = SelectedAgency;
???? this is where i use to get count where in other buttons and are displayed.... but i changed the query to display only the Payment_Amount_Budgeted respective to the agency selected. from the viewRUN_SQLCONDITION = "SELECT Payment_Amount_Budgeted FROM dbo.V_Payment_Amount_List " + SQLCONDITION;
try
{
CollectionCount = ConnectionFinanceDB.CollectedFinaceDataCount(RUN_SQLCONDITION);
EnrollAmtBTM.Text = CollectionCount.ToString();
}
catch
{
}////this is my CollectedFinaceDataCount-- where fuction counts the records in the above select statement if i use for eg.
"SELECT Count(Placement_Retention_ID) FROM dbo.V_Retention_6_Month_Finance_Payment_List"
here is the functionpublic int CollectedFinaceDataCount(String SQLStatement)
{int DataCollection;
DataCollection = 0;
try
{
SQLCommandExe = FinanceConnection.CreateCommand();
SQLCommandExe.CommandType = CommandType.Text;
SQLCommandExe.CommandText = SQLStatement;
ConnectToDatabase();DataCollection = (int) SQLCommandExe.ExecuteScalar();
DisconnectToDatabase();
}catch (Exception ex)
{Console.WriteLine("Exception Occurred :{0},{1}",
ex.Message, ex.StackTrace.ToString());
}
return DataCollection;
}
So here mu requirement request is to display only the value fronm the view i have against the agency selected
Please help ASAP
Thanks
Santosh
View 8 Replies
View Related
Jan 18, 2008
I need to retrieve points column from my database for the specific user that is signed on and sum all of them. How can I do it using the Gridview and also code in vb for a label? Thanks.
View 4 Replies
View Related
Nov 19, 2005
Here is my sql procedure:
ALTER PROCEDURE dbo.SoftWareShow /* ( @parameter1 int = 5, @parameter2 datatype OUTPUT ) */ @SoftID uniqueidentifierAS SELECT [SoftID], [SoftName], [SoftJoinDate], [SoftSize], [SoftMode], [SoftRoof], [SoftHome], [SoftDemo], [SoftFirstClassID], [SoftSecondClassID], [SoftDesc], [SoftReadCount], [SoftDownCount],ltrim(rtrim([SoftUrlOne])) SoftUrlOne, ltrim(rtrim([SoftUrlTwo])) SoftUrlTwo, ltrim(rtrim([SoftUrlThree])) SoftUrlThree, ltrim(rtrim([SoftUrlFour])) SoftUrlFour FROM [SoftWare] WHERE ([SoftID] = @SoftID) RETURNwhere I retrieve data using sqldatasource, an error appear. how can do ?
View 1 Replies
View Related