Correct Type For Operation: DataAdapter Vs. DataReader
Apr 8, 2008
I am reading multiple databases into a single dataset, putting each read into a new datatable in the set. Ultimately, I want to merge the multiple tables (they are all from different DB tables in different locations using the same schema). I am also combining this with data from an Oracle database which is in yet another table in the same dataset.
Here is my question:
I will not be propagating any changes to this data back to its original source, but I will be populating it out to Active Directory. (Don't worry; I'm not asking any AD questions here.) But I do want to run SELECT, DELETE, and UPDATE queries against the data in the dataset in memory without writing it out to a separate file. Based on that type of usage, would I be better to use a DataReader or a DataAdapter to do the read from the original database? If I use a DataReader, can I still update the data in memory? In either case, what's the correct methodology to update data in a dataset in memory?
Hi, What is the difference b/w sqldatareader and sqldataadapter? For what purpose are they used in a database connection & how do they differ from each other? Pls explain me in detail.Regards Vijay.
Dear All! I have a script task that try to connect to a computer. In script task, I use code as following:
Try Directory.GetFiles(ReadVariable(strFullPath) Catch ex As Exception Catch
Dts.TaskResult = Dts.Results.Failure End try
In the case, strFullPath is IP address instead of ServerName then package run is not correct. (EX: strFullPath = \10.16.45.89TestFolder, Of course, This path is exist). Its a trange at that: When I run package form source then its suucess. But When I run it from Job of SQL Agent then its fiailure. Pls help me to solve this problem. Thank a lot!
In my DAL:using System;using System.Collections;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public DataReader getPersonList2() { using (SqlConnection conn = getConnection()) { SqlCommand cmd = new SqlCommand("PERSON_SP_getPersonList", conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); return cmd.ExecuteReader(); } }In my BLL:using System;using System.Collections;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;DAL d = new DAL();public DataReader getPersonList2(){ return d.getPersonList2(); }I get the following error in my BLL: Compiler Error Message: CS0246: The type or namespace name 'DataReader' could not be found (are you missing a using directive or an assembly reference?) Source Error:
Line 34: }Line 35: Line 36: public DataReader getPersonList2(){Line 37: return d.getPersonList2();Line 38: }
Source File: c:InetpubwwwrootstudyApp_CodeBLL.cs Line: 36 Just wondering if someone could tell me why this is happening? I have the same namespaces that I have in the DAL in my BLL.Puzzled.
Hi,I want to have all-in-one trigger, defined like this:CREATE TRIGGER MyInsertDeleteUpdateHandlerON MyTableFOR DELETE, INSERT, UPDATEASBEGIN(...)ENDNow, how can I tell why this trigger was fired (what event causedtrigger to be fired) - was it DELETE, INSERT or UPDATE?Is there something like this: @@event_type,so I could do for example IF (@@event_type = DELETE) (...)Of course I can create 3 triggers instead of 1, to be sure what eventfired my trigger.I can also count records in _deleted_, _inserted_ tables or to doJOINs with it. But, _inserted_ table is common for UPDATE and INSERTevents..Any suggestions?Thanks in advance.Hubert
I recently upsized my acess 2000 db to SQL 2000, but I am now having errors . . .
Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E07) [Microsoft][ODBC SQL Server Driver][SQL Server]The sum or average aggregate operation cannot take a nvarchar data type as an argument. /data_count.asp, line 4
The code within the asp file: <% dataSQL = "SELECT SUM(filesize) FROM DL where show=1" Set datacount = my_Conn.Execute(dataSQL) anBytes = datacount(0) %>
how to solve this problem .... I want to select te sum of nvarchar column and this error always happen
what is the solution this is my query
"SELECT Datein AS Date,SUM(Durm) AS DurationMin, COUNT (*) AS 'Number of Hits' FROM Rayyan_Log WHERE (DNIS = '"+DropDownList1.SelectedItem.Text +"') AND (Datein between '"+TextBox2.Text+"' and '"+TextBox3.Text+"') GROUP BY Datein ORDER BY Datein"
How can I make it work when I need to pull out a field which is text type using a stored procedure? Please help!!!Thanks I am getting the following error Error 409: The assignment operator operation could not take a text data type as an argument ===========my sp================================= CREATE PROCEDURE [dbo].[sp_SelectABC] (@a varchar(50) output, @b text output ) AS set nocount on select @a=name, @b= description from ABC
While doing performance testing on a Tomcat based web application using the v1.1 JDBC driver connecting to SQL Server 2005, the tomcat server has been throwing the above exception at a fairly low rate. I have seen some related issues in the forums with v1.1 of the MS JDBC driver, but those were asking about connection reset related errors. In this case the 'invalid packet header' exception is consistently seen. I am in the process of repeating the test with some additional application side logging turned on, and have tried enabling FINEST level logging for the driver, but that leaves me with a 500MB log file and so far no instances of that exception in question being thrown. This is not unusual, the error has only been seen about 14 times in about 20 tests, with each test running about an hour and a half.
A few quick tests with the 1.2 driver did not throw this exception, but did throw a high number of '[Connection|Statement|Resultset] Closed'
While I gather more information, I was wondering if there is anything significant in this particular exception type that could point to a more specific set of tests I could run?
The exceptions seen so far:
Exception #1:
java.lang.NullPointerException at com.microsoft.sqlserver.jdbc.DBComms.receive(Unknown Source) at com.microsoft.sqlserver.jdbc.DBComms.receive(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.doCloseServerCursor(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement$CloseServerCursorRequest.execute(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.closeServerCursor(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerResultSet.close(Unknown Source) at com.X.db.CSInternalDB.close(CSInternalDB.java:950) at com.X.db.CSQuery.close(CSQuery.java:169) at com.X.container.ContainerManager.getFolderContent(ContainerManager.java:1313) at com.X.container.ContainerCommands.getContent(ContainerCommands.java:1086) at com.X.container.ContainerCommands.execCommand(ContainerCommands.java:192) at com.X.BaseHandler.getObjectFromDoc(BaseHandler.java:169) at com.X.BaseHandler.processDOM(BaseHandler.java:284) at com.X.Dispatcher.execIt(Dispatcher.java:546) at com.X.Dispatcher.execCommand(Dispatcher.java:333) at com.X.BaseHandler.getObjectFromDoc(BaseHandler.java:169) at com.X.X.execute(X.java:600) at com.X.HttpReceiver.doRequest(HttpReceiver.java:275) at com.X.HttpReceiver.doGet(HttpReceiver.java:181) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.cluster.tcp.ReplicationValve.invoke(ReplicationValve.java:346) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Unknown Source)
#2:
java.sql.SQLException: The DBComms.receive operation resulted in an invalid packet header type:-86. PktNum:0. nReceived:8. at com.X.db.CSPreparedStatement.executeQuery(CSPreparedStatement.java:474) at com.X.db.CSAnalyzer.executeQuery(CSAnalyzer.java:485) at com.X.db.CSQuery.sqlPrepareExecute(CSQuery.java:559) at com.X.form.FormManager.getInternalFormProps(FormManager.java:1803) at com.X.form.FormManager.getInternalFormProps(FormManager.java:1762) at com.X.route.RoutingCommands.genericPrepareRoutingPage(RoutingCommands.java:5618) at com.X.route.RoutingCommands.prepareRoutingPage(RoutingCommands.java:3899) at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.X.iplugin.DynamicCommandMethod.execute(DynamicCommandMethod.java:35) at com.X.route.RoutingCommands.execCommand(RoutingCommands.java:209) at com.X.BaseHandler.getObjectFromDoc(BaseHandler.java:169) at com.X.BaseHandler.processDOM(BaseHandler.java:284) at com.X.Dispatcher.execIt(Dispatcher.java:546) at com.X.Dispatcher.execCommand(Dispatcher.java:333) at com.X.BaseHandler.getObjectFromDoc(BaseHandler.java:169) at com.X.X.execute(X.java:600) at com.X.HttpReceiver.doRequest(HttpReceiver.java:275) at com.X.HttpReceiver.doGet(HttpReceiver.java:181) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.cluster.tcp.ReplicationValve.invoke(ReplicationValve.java:346) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Unknown Source)
My question here is as the dimension has SCD type 2 on it and every time when there is a change the persn_key gets a new key value but the fact table still points to oldest key.how to update the surrogate key on fact table to the current key value? As per the requirement fact surrogate key must be pointing to current active record on the dimension.
I'm using SQL Server 2012 Analysis services in Tabular mode and connected to Oracle Database and while importing, I'm getting below error after importing some rows.
OLE DB or ODBC error: Accessor is not a parameter accessor.. The current operation was cancelled because another operation in the transaction failed.
Why DataAdapter does NOT load relations from DB ?the relations are made using SQL SERVER MANAGEMENTbut when a fill a datatable using dataadapter the relations are not loaded .why ? what is the solution to this problem ?
Hi i'm a new to ASP.NET and for some reason when i click the Next button in the code below, the pageIndex does not change. Please assist, Basically what i'm trying to do is to use DataAdapter.fill but passing in the start index and the number of records to pull from the dataset table. using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; public partial class Home : System.Web.UI.Page { //ConnectionOleDbConnection dbConn; //discount that can be change by user using a gui interface //CurrentPageint pageIndex = 0;double discount = 0.15 ; protected void Page_Load(object sender, EventArgs e) { // homeGridView.Visible = true;
BindList();
}protected string getSpecial(string price,object sale) {String special = "";if (sale.ToString().CompareTo("True") == 0) {special = String.Format("{0:C}",double.Parse(price) * (1-discount)); }return special; } protected void BindList() { //Creating an object for the 'PagedDataSource' for holding the data.
//PagedDataSource objPage = new PagedDataSource(); try { //open connection openConnection(); //sql commandstring columns = "*"; string SqlCommand = "Select " + columns + " from Books"; //create adapters and DataSetOleDbDataAdapter myAdapter = new OleDbDataAdapter(SqlCommand, dbConn);DataSet ds = new DataSet("bSet");
//create tableDataTable dt = new DataTable("Books");myAdapter.Fill(ds, pageIndex, 9, "Books");
Response.Write("Page Index: "+pageIndex); //create table data viewDataView dv = new DataView(ds.Tables["bTable"]); booksDataList.DataSource = ds; booksDataList.DataBind();
I have done some reading on the dataadapter class, but do not have a good handle on how to work with dataadapter after it has been filled by a dataset. For instance, should I use an if statement such as this to update the value in the dataadapter? if (dsSunbelt.Tables[0].Columns[39].Equals("")) { DataRow drUpdate = dsSunbelt.Tables[0].Columns[39].Equals(DateTime.Now); } I am sure it is not hard to see what I am doing, and I hope that I am missing something small, but how do I isolate a dataadapter value to update in the corresponding database?
Hi, I am populating a datagrid with data from one sql table, I add additional columns and then wish to write it back out to another table. I have written the following code to acheive this, however it keeps throwing the follwing exception - "Update requites a valid UpdateComman when passed a DataRow collection with modified rows" I've looked and I can see what the problem is, can anybody help please? Private Sub FillData() 'SQL connection Me.sqlconnection = New System.Data.SqlClient.SqlConnection Me.sqlconnection.ConnectionString = ConfigurationSettings.AppSettings("CuroConnection")
Dim sql As String If Request("action") = "gen" Then sql = "select item from tblPickList where GroupName = 'xxx'AND Category = '" & Category2 & "' ORDER BY item ASC" ElseIf Request("action") = "fav" Then sql = "select identifiertext as item from tblfavourites where HRID = " & Session("hrid") & " and type = 3 ORDER BY identifiertext ASC" ElseIf Request("action") = "spec" Then sql = "select item from tblPickList where GroupName = '" & GroupID & "' AND Category = '" & Category2 & "' ORDER BY item ASC" End If
ds = New DataSet da = New SqlClient.SqlDataAdapter(sql, sqlconnection)
Try sqlconnection.Open() da.Fill(ds, "tblPickListTemp") sqlconnection.Close() Catch ex As Exception sqlconnection.Close() End Try
ds.Tables(0).Columns.Add("HRID") ds.Tables(0).Columns.Add("Flag") 'may possibly add a favourites column here at a later date to ensure no duplication
Dim dr As DataRow For Each dr In ds.Tables("tblPickListTemp").Rows dr("HRID") = Session("hrid") dr("Flag") = 0 Next
DgrdFavourites.DataSource = ds DgrdFavourites.DataBind() End Sub
Public Sub CreateTempRecords()
'SQL connection Me.sqlconnection = New System.Data.SqlClient.SqlConnection Me.sqlcommand = New System.Data.SqlClient.SqlCommand Me.da = New SqlClient.SqlDataAdapter Me.sqlconnection.ConnectionString = ConfigurationSettings.AppSettings("CuroConnection")
Dim sql As String sql = "Insert into tblPickListTemp (Item, HRID, Flag) values (@Item, @HRID, @Flag)" sqlcommand.CommandText = sql sqlcommand.Connection = sqlconnection
sqlcommand.Parameters.Add("@Item", "Item") sqlcommand.Parameters.Add("@HRID", "HRID") sqlcommand.Parameters.Add("@Flag", "Flag") da.InsertCommand = sqlcommand da.Update(ds.Tables(0)) End Sub
I'm reading XML data into a DataTable that is populated into a datagrid. From here I need to update database and wanted to know how to Fill a DATA ADAPTER with a DATA TABLE? I'm familiar with updating using a SQL command, but in this case, i have the dataTable already created from XML. Please help. Thanks,
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 41: DataSet dataset = new DataSet();Line 42: Line 43: dataAdapter.Fill(dataset, "Products");Line 44: SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter);Line 45: Source File: e:asp.net egisteration egister.aspx.cs Line: 43 Stack Trace:
SqlDataAdapter dataAdapter = new SqlDataAdapter(strCommand, strConnection);
DataSet dataset = new DataSet();
dataAdapter.Fill(dataset, "Products");
SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter);
DataTable dataTable = dataset.Tables[0];
dgCustomer.DataSource = dataTable;
dgCustomer.DataBind();
} }
when i run this code, error like this appear :
Server Error in '/Registeration' 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 41: DataSet dataset = new DataSet();Line 42: Line 43: dataAdapter.Fill(dataset, "Products");Line 44: SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter);Line 45: Source File: e:asp.net egisteration egister.aspx.cs Line: 43 Stack Trace:
this does not work, it does work however if i replace the Me.textboxhello.Text with a value in quotation marks or with another text box not linked to that feild in the table... it does not work with the relevant text box!!!!!!!!
Hy, again! I am at the begining of an application. I have some modules that insert, delete and update only one row at one table. My question is should I use dataadapter.Update() or ExecuteNonQuery(). I prefer ExecuteNonQuery because I want to build a class : DataLayer to implement my own InsertProcedure(), UpdateProcedure(),DeleteProcedure(). I want speed in my application, so which is the best: dataadapter.Update() OR ExecuteNonQuery(). Thank you!
Good day, I just like to ask if anybody has experienced getting empty rows from SQL data adapter? I'm using SQL Server 2005. Problem is when the sql is run on Query Analyzer it retrieves a number of rows but when used in my application it returns 0 or empty rows. I thought the connection is not the problem since I got my columns right. Below is my code snippet. Thanks! const string COMMAND_TEXT = @"select distinct somefield as matchcode, count(somefield) " + "as recordcount from filteredaccount where StateCode = 0 group by somefield having count(somefield) > 1"; SqlDataAdapter adapter = new SqlDataAdapter(COMMAND_TEXT, connection); DataTable dt = new DataTable(sometablename); adapter.Fill(dt);
For some reason I've had trouble with this today... can anyone provide me with a generic code snippet that programatically allows me to select data from a database limited by a parameter and then fills a datatable?
I am having trouble getting an Update call to actually update records. The select statement is a stored procedure which is uses inner joins to link to property tables. The update, insert, and delete commands were generated by Visual Studio and only affect the primary table. So, to provide a simple example, I have a customer table with UID, Name, and LanguageID and a seperate table with LanguageID and LanguageDescription. The stored procedure can be used to populate a datagrid with all results (this works). The stored procedure also populates an edit page with one UID (this works). After the edit is completed, I attempt to update the dataset, which only has one row at this time, which shows that it has been modified. The Update modifies 0 rows and raises no exceptions. Is this because the update, insert, and delete statements do not match up one-to-one with the dataset? If so, what are my choices?
I'm using DataAdapter.Update() to update data in a table. My question is; how do I create a trigger that works after the update has completely finished?
For example if my update adds 50 new rows to a table the trigger I've currently got fires after each new row that is added ie 50 times in total. Is it possible to get it to trigger after the last (ie 50th) row is added???
hi friends, i look forward an answer that solves my problem. iam trying too populate a DropDown list . here is the codings. Previously it was working. suddenly, it s generating error. strConnectionString = "Provider = SQLOLEDB;Integrated Security=False; User ID=sa;Password=;Data Source=GIREESH-AC720F7;Initial Catalog=NorthWind"
in page_load event dim sql as string sql = "select AthleteNameKey from athletes" result_adap = DbAccess.ExecuteAdaP(sql) result_adap.Fill(result_ds, "athletes") cboAthleteName.DataSource = "athletes" cboAthleteName.DataTextField = "AthleteNameKey" cboAthleteName.DataValueField = "AthleteNameKey" cboAthleteName.DataBind()
Public Function ExecuteAdaP(ByVal sqls As String) As OleDbDataAdapter 'Dim ds As New OleDbDataAdapter Dim da As New OleDbDataAdapter(sqls, strConnectionString) 'da.Fill(ds) Return da End Function
I am trying to insert data into 2 different tables. I am using dataadapter and dataset.
Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click Call ConnectionString()
Dim insertSQL As New SqlCommand() insertSQL.Connection = sqlConn insertSQL.CommandText = "SELECT location.CountryName, location.CityName, location.BuildingName, location.FloorID, rooms.name, rooms.FloorID AS Expr1 FROM location INNER JOIN floors ON location.FloorID = floors.id INNER JOIN rooms ON floors.id = rooms.FloorID"
Dim ds As New DataSet() Dim da As New SqlDataAdapter()
da.SelectCommand = insertSQL Dim scb As New SqlCommandBuilder(da)
Try da.Fill(ds) Dim ndr = ds.Tables("location").NewRow Dim ndr2 = ds.Tables("rooms").NewRow
My DataAdapter.Update() Method is running this query against my database and all the parameters and the formatting looks correct to me. I was wondering if anyone could identify obvious errors.... Thanks!
My task is to bind and show 3 different values coming from three different queries into three different columns of GridView. I had done this as mention in below. Program was successful. But I want to excute these three queries in same Stored Procedure. I can do that and stored in seperated variables. I need help how to call these three different values in data adapters and store each value in three different columns of grid view.
Simply I want to below statement in stored procedures and call from program. Can any one help me plz.
con = DataBaseConnection.GetConnection();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select isnull(sum(PA_DAmt),0) from PA_Deposits where PA_UID = @PA_UID", con); da.SelectCommand.Parameters.Add("@PA_UID", SqlDbType.Int).Value = Convert.ToInt32(Session["PA_UID"]); da.Fill(ds,"Dep");
SqlDataAdapter da1 = new SqlDataAdapter("select isnull(sum(PA_EAmt),0) from PA_Expenses where PA_UID = @PA_UID", con); da1.SelectCommand.Parameters.Add("@PA_UID", SqlDbType.Int).Value = Convert.ToInt32(Session["PA_UID"]); da1.Fill(ds,"Exp");
SqlDataAdapter da2 = new SqlDataAdapter("select isnull(sum(PA_IAmt),0) from PA_Income where PA_UID = @PA_UID", con); da2.SelectCommand.Parameters.Add("@PA_UID", SqlDbType.Int).Value = Convert.ToInt32(Session["PA_UID"]); da2.Fill(ds,"Inc");
// This is another way I had tried. But failed. I am getting Index out of bound error. Can any solve this if possible to u. SqlCommand cmd = new SqlCommand("select isnull(sum(PA_DAmt),0) from PA_Deposits where PA_UID = @PA_UID", con); cmd.Parameters.Add("@PA_UID", SqlDbType.Int).Value = (int)Session["PA_UID"]; GridView1.Rows[0].Cells[1].Text = cmd.ExecuteScalar().ToString();
cmd.CommandText = "select isnull(sum(PA_EAmt),0) from PA_Expenses where PA_UID = @PA_UID"; GridView1.Rows[0].Cells[2].Text = cmd.ExecuteScalar().ToString();
cmd.CommandText = "select isnull(sum(PA_IAmt),0) from PA_Income where PA_UID = @PA_UID"; GridView1.Rows[0].Cells[3].Text = cmd.ExecuteScalar().ToString();
ASPX Code for Grid View <h2>Account Summary</h2><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" emptydatatext="There are no data records to display." Width="238px" > <Columns> <asp:TemplateField >
as far as I know from docs and forum datareader is for .NET data in memory. So if a use a complex dataflow to build up some data and want to use this in other dataflow componens - could i use data datareader source in the fist dataflow and then use a datareader souce in the second dataflow do read the inmemoty data from fist transform to do fursther cals ?
how to pass in memory data from one dataflow to the next one (i do not want to rebuild the logic in each dataflow to build up data data ?
Is there a way to do this ? and is the datareader the proper component ? (because its the one and only inmemory i guess, utherwise i need to write to temp table and read from temp table in next step) (I have only found examples fro .NET VB or C# programms to read a datareader, but how to do this in SSIS directly in the next dataflow?
Hey guys, whats an easy way to pass a value into a stored procodure? I tried the code below but I keep on getting a "Procedure 'sp_InsertData' expects parameter '@gpiBatchNo', which was not supplied." error. My stored proc basically gets inserts the passed variable into a databaseSqlConnection sqlSecConnection = new SqlConnection(sqlPriConnString);SqlCommand sqlSecCommand = new SqlCommand(); sqlSecCommand.Connection = sqlSecConnection; sqlSecCommand.CommandText = "sp_InsertData";sqlSecCommand.CommandType = CommandType.StoredProcedure;sqlSecCommand.Parameters.Add("@gpiBatchNo", SqlDbType.NVarChar) ; sqlSecConnection.Open();int returntype = sqlSecCommand.ExecuteNonQuery(); sqlSecConnection.Close();