ExecuteReader Error A Parameter Is Missing [Paremeter Ordinal = 1]

Sep 24, 2007

Hello and thanks in advance.

This error was received executing a SqlCeCommand method of ExecuteReader();

I have only found 3 hits in Google about this error and the time it was asked in a MS forum it was not answered. I need an answer, please.

bombar...see code below


SqlCeDataAdapter adp = null;

adp = new SqlCeDataAdapter();

SqlCeCommand cmd;

cmd = _Con.CreateCommand();

cmd.CommandType = CommandType.Text;

cmd.CommandText = "insert into InventoryCounts(DateTime,WarehouseID,PartID,LotID,UserName,Count) VALUES(?,?,?,?,?,?)";

adp.InsertCommand = cmd;

cmd = _Con.CreateCommand();

cmd.Parameters.Clear();

SqlCeParameter p1 = cmd.Parameters.Add("DateTime",SqlDbType.DateTime);

SqlCeParameter p2 = cmd.Parameters.Add("WarehouseID",SqlDbType.NChar,20);

SqlCeParameter p3 = cmd.Parameters.Add("PartID", SqlDbType.NChar,20);

SqlCeParameter p4 = cmd.Parameters.Add("LotID", SqlDbType.NChar,20);

SqlCeParameter p5 = cmd.Parameters.Add("UserName", SqlDbType.NChar,20);

SqlCeParameter p6 = cmd.Parameters.Add("Count", SqlDbType.Int);

p1.Value = Convert.ToString(DateTime.Now);

p2.Value = "Warehouse1";

p3.Value = txtBPartIDShow.Text;

p4.Value = txtBLotIDEntry.Text;

p5.Value = "JHB";

p6.Value = Convert.ToInt32(txtBCountEntry.Text);



cmd = _Con.CreateCommand();

cmd.CommandType = CommandType.Text;

cmd.CommandText = "insert into InventoryCounts(DateTime,WarehouseID,PartID,LotID,UserName,Count) VALUES(?,?,?,?,?,?)";

cmd.Prepare();

cmd.ExecuteReader();

View 4 Replies


ADVERTISEMENT

Parameter Is Missing A Value Error Only When I Deploy

Sep 7, 2006

Report X passes all it's parameters to Report Y via a "jump to report". Report Y then populates a select box based on the parameters passed to it. The user selects one of these values and clicks "View Report". This works perfectly in the development environment. But when I deploy it to the server I keep getting an error when I click the link that jumps to Report Y.

Here's the error: "The 'B' parameter is missing a value"

The problem is.. I don't want to pass the B parameter to Report Y. I want the user to select this from a list. I'm very confused as to why this would work in the development envionment but not when deployed.

Any Ideas?

View 3 Replies View Related

Error The Parameter Is Missing A Value: Problem With Parameters ('Ver 1.1 Part 1') Passing To Report Viewer Control

Jan 25, 2008



Hello,

I am passing the partameters to MS Report Viewer control to view the report. It is working fine with normal parameters like 'abc', 'Jon' etc.
But fails with parameters having special characters like 'abc+', 'Version 1.1 Part 1', 'R1.8 RC' throws error "
The parameter is missing a value"



Could anyone please help on this.

Thanks,
Chandroday

View 1 Replies View Related

SQL Server 2008 :: BCP XML File Format Error Invalid Ordinal For Field 2

Oct 1, 2010

When creating xml fileformat its throwing me error "invalid ordinal".

When created non-xml file format, no error, and was also able to load data file into sql table. Not sure why bcp (Version: 10.50.1600.1) is not able to create xml file format.

C:>BCP "MyGDB.dbo.Items_Import" format nul -f"C:AnkitTempBCPItemsMaster.xml" -x -w -T -S"(Local)"

SQLState = HY000, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid ordinal for field 2 in xml format file.

Column_nameTypeComputedLengthPrecScaleNullableTrimTrailingBlanksFixedLenNullInSourceCollation
Item Numbervarcharno18 noyesnoSQL_Latin1_General_CP1_CI_AS
Description1nvarcharno80 yes(n/a)(n/a)SQL_Latin1_General_CP1_CI_AS
Description2nvarcharno80 yes(n/a)(n/a)SQL_Latin1_General_CP1_CI_AS
UMvarcharno3 yesyesyesSQL_Latin1_General_CP1_CI_AS

View 1 Replies View Related

Reporting Services :: Passing Parameter Via URL Using Javascript - Missing Parameter Value

Dec 3, 2015

Using SQL Server 2008R2 and Report Builder 3.0..I have an action set in a text box of a table. My intent is to pass the value of that text box (which is variable) to a sub-report in a popup window. Here's my code: URL....The parameter of the report I'm trying to open is @SONum.I'm guessing my error is involved in the formatting of how the value of the parameter is being passed. I've also seen examples where the report server and report values were parameterized, but I don't know where to define

Parameters!ServerAddress.Value anywhere.Do I need to have something set up a certain way within the report I'm opening? Here's the report Parameter settings on the report I'm trying to open.

View 3 Replies View Related

How To Pass Paremeter To A Select Statement?

Jul 28, 2006

I have this.
string strConn = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString; string strQuery = "SELECT * FROM enews WHERE ((name_nws LIKE %'" + strSearch + "'%)"; SqlDataAdapter newsResultAdapter = new SqlDataAdapter(strQuery, strConn); //create a new dataset DataSet dsNewsSearch = new DataSet(); //populate the dataset with the "board_mtg_date" table from the database newsResultAdapter.Fill(dsNewsSearch, "enews"); //go through each rows in the dataset foreach (DataRow dr in dsNewsSearch.Tables[0].Rows) { int newsID = Convert.ToInt16(dr["id_nws"]); } I'm trying to pass a value to the Select statement with the variable "strSearch". It kept giving me error on this section.
The error is:
[SqlException (0x80131904): Line 1: Incorrect syntax near 'Challenge'.]"Challenge" is the text I passed it in.

View 17 Replies View Related

Parameter Is Missing A Value

Mar 6, 2006

I have a report parameter with Allow null value checked (and also Allow blank value). The report works as expected when viewed in Visual Studio, i.e. if I don't supply a value for the parameter, the report still renders. However, when I try to view this report through the web ReportViewer I get the error message "The X parameter is missing a value". It works fine when a value is supplied but I want that parameter to be optional.

Any idea what's going wrong here?

Thanks.

View 9 Replies View Related

Parameter Is Missing A Value.

Sep 11, 2007

Hi Friends,

I have created a child report with hidden parameter. When I call this report from the Master report using a link, I am getting error 'the xxxx parameter is missing a value'.
From, master report, if I click a value, it should take that value to child report where it filters for that value and should display the child report.


How to overcome this?

Thanks & Regards,
Naveen J V

View 14 Replies View Related

Missing SP Parameter?

Sep 20, 2007

I've got a completely goofy problem on one development machine running Vista, SQL 2005 sp2, and Orcas Beta 2. I'm calling a stored proc from within my C# and my ExecuteDataReader() command fails saying I'm missing a parameter (which I'm not).

The c# looks like this:


if (SqlContext.IsAvailable)

{
using (System.Data.SqlClient.SqlConnection cnx =


new System.Data.SqlClient.SqlConnection("context connection=true"))

{


cnx.Open();

using (SqlCommand xCmd = new SqlCommand("dbo.TestMe", cnx))

{


xCmd.CommandType = CommandType.StoredProcedure;

xCmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("myParam", SqlDbType.Int));

xCmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("myStr",








SqlDbType.VarChar, 150));

xCmd.Parameters["myParam"].Value = 123;

xCmd.Parameters["myStr"].Value = "Hello";

xCmd.ExecuteNonQuery();

}
}

}

My Stored Proc look like this:


CREATE PROCEDURE [dbo].[TestMe]


@myParam as int,

@myStr as nvarchar(150)

AS

BEGIN


SELECT 1 as myCol

END



The result is a an exception that looks like this:


A .NET Framework error occurred during execution of user-defined routine or aggregate "StoredProcedure1":

System.Data.SqlClient.SqlException: Procedure or function 'TestMe' expects parameter '@myParam', which was not supplied.

If I run the SP from the Sql Workbench, it looks fine. Any ideas? I just repaved SQL and Orcas on this machine to see if I can fix the problem -- no luck.

View 3 Replies View Related

Parameter Is Missing A Value

Apr 8, 2008

Hi!

For display a Field Dataset in my header i created a parameter with that field using "From query" in parameter window and then showed the parameter in the header.

All works fine but when the dataset returns nothing i receive the error "parameter is missing a value".

How i Can show fields of my dataset in the header without this problem?

Thanks!


View 4 Replies View Related

Parameter Is Missing A Value

Mar 21, 2007

Hi Folks,

I'm receiving the "Parameter is missing a value" error message while testing my report.
I have five parameters, two of which are hidden that gets prefilled from the query below. The hidden parameters are DatatechClient and DatatechProduct.
SELECT ClientNameProduct, DatatechClient, DatatechProduct
FROM V_TranslationTable
WHERE (CMRNum = @Cmr) AND (AcctNum = @ClientNum)
Three parameters are shown and the report works fine as long as the CMRNum and AcctNum is found in the V_TranslationTable however, the error generates when they are not found. I looked through the other threads in this forum that deals with "Parameter is missing a value" but it didn't appear to be a solution shown.
Thanks in advance for any assistance you give.

View 3 Replies View Related

Parameter Is Missing In A Dts Package

Jun 26, 2001

Here is the problem.

SQL server 7.0 running Service Pack 2.0 has some DTS packages on it. A user puts service pack 3.0 on his workstation. Now we cannot open the package.
We are getting the Parameter is missing errror message. I remember somewhere you go and change a binary setting. Does anyone know how we can fix this?

Thanks,
Dianne

View 3 Replies View Related

ReportViewer - Parameter Is Missing A Value

Jan 11, 2008

Here's my situation. I've got a report with some report parameters defined. These parameters get their available and default values from a query. I've got a Dataset and respective fields selected. The dataset in question is sort of a "headings" dataset, which only ever has one row. Now this works just fine when I'm previewing the report in designer, grabs the value, uses it as I'd expect. The problem is occuring when I'm using the WinForms ReportViewer control to view my report.

I'm not deploying this report, but running it client-side in the WinForms ReportViewer control. I'm providing it with the relevant datasets, bound appropriately (I can pull data from the fields directly in the report just fine), but when I try and view the report I get "The 'xyz' parameter is missing a value".

What's going on here? The definition seems acceptable as it works fine in designer, and my execution using the WinForms ReportViewer also seems to be correct, as I can use the fields otherwise. It just falls apart on the parameter default value from a query.

View 3 Replies View Related

Parameter Missing Value After Deployment

Sep 24, 2007

Hi Friends,

I'm using MSRS 2005. I have created a drillthrough report using parameter. If I try to execute locally it works fine. I am able to call sub report from the master report by passing parameter. But, If I rey to access the report after deploying on to reporting server, I am getting error patameter xxxx is missing a value. What could be wrong? Please help

Thanks & Regards,
Naveen J V

View 7 Replies View Related

Missing Parameter Value After Drill-through

Feb 5, 2008


Hi Friends,

I have a problem concerning parameters on subreports.

My main report contains a list of meetings. You can click on any meeting name for a drill-through to get a detailed subreport of that meeting.
Now I wanna give the user the possibility to enter some parameter values for that subreport, before the subreport opens.
But I get an error message that my parameter value (for the subreport) is missing.
The funny things is, that when I open the main-report in Visual Studio everthing works fine. I drill-through to the subreport and I'm asked to enter a parameter value (parameter pane) for the subreport which shows up right after that.

I also tried to build a work-around by adding the parameters for the subreport in the mainreport and passing them.
This worked, but when the subreport shows up the parameter pane is always faded out, so that the user can't see which parameter value is used or can't change it. Is there a possibility to always have the parameter pane "on"?

Thanks in advance for your support

View 6 Replies View Related

Reporting Services :: Parameter Is Missing A Value

Nov 9, 2008

I have an issue where I need to set a whole bunch of internal parameters' values to the result of a dataset first executed with the report...nothing new or majestic about it.
 
The problem is that the 'First dataset', under some parameter values, return no records..it is empty (which is fine). But this meas that these internal parameters error my report as the 'NEED' a value even though I have specified a default, I still get the 'Paremeter X is missing a value' error. I just want the other datasets, which are reliant on these erroring parameters to either execute with parameter values of 0 or not execute at all. Thus I want the sub datasets to return with blank data in this case or not execute at all.
 
How can I achieve this?

View 10 Replies View Related

Jump To Report - Parameter Missing Value

Nov 30, 2007



Hello

I have set up a report with a field in a list as a link to another report . I am passing all the parameters in correctly (4 parameters : 1 from a field value and 3 from parameter values). When I run the report and click the link, it jumps to the other report but one parameter is missing a value - the parameter I got from the field value. I really don´t know why this is happening as it was working fine until I added another parameter to the reports and suddenly it doesn´t work anymore.

Is there a limit on the number of parameters I can pass or something?

Please help!

View 5 Replies View Related

Problem With SQL SQLCECommand - Missing Parameter

May 30, 2007

Have a nice day. I'm developing for PocketPC using VB2005 and SQLMobile and need some help to solve the following issue:

At runtime the following code throws an exception #25950 SSCE_M_QP_MISSINGPARAMETER

Missing Parameter [Parameter ordinal = 1]

Everything looks fine, but it still fails. In the same app I have a datagrid connected via a dataset and it works OK. Please give me directions!!



Dim conn As SqlCeConnection = Nothing

Try

conn = New SqlCeConnection("Data Source =" & _

(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase) + "db.sdf;"))

conn.Open()

Dim cmd As SqlCeCommand = conn.CreateCommand

cmd.CommandText = " INSERT t_People ([txt_Name], [txt_LastName]) VALUES ('CLARK', 'KENT') "

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox(ex.ToString)

Finally

conn.Close()

End Try





View 11 Replies View Related

Report Viewer Parameter Missing A Value

Mar 25, 2008



Hi,
I am using Microsoft.ReportViewer.WebForms ver 8.0 to display rdl reports in a web page. I'm using VS 2005 with service pack 1.
I set ReportServerCredentials using a custom class that implements IReportServerCredentials. It exposes NetworkCredentials using a valid admin user account. I am setting report parameters from code as:

ReportViewer1.ServerReport.SetParameters(parameters)

I find that when I run the page with reportserver credentials set, the parameters are not passed to the report and I get an error message, "Parameter, XXX is missing a value". I can see what parameters were sent by setting ShowParameterPrompts to True.
When I remove the credential settings,the parameter values do get set but the report throws the following error on execution:

Execution '2su5vg55juj253455rodai55' cannot be found
I have checked that my web project is using Kerberos authentication and not NTLM. Has anybody faced a problem like this? I would appreciate any help.
Thanks
Supriya

View 1 Replies View Related

'SqlCeException - A Parameter Is Missing' After Migration To SQLServerCompactEdition 3.5

Jan 21, 2008

Hi,

after migration my project to CF 3.5 and SQlCe 3.5 I got the following error message:

System.Data.SqlServerCe.SqlCeException - A parameter is missing. [ Parameter ordinal = 1 ]

I'm using the same code:

Public Sub Update(oSqlCEConn As SqlCeConnection, oSqlCEAdapter As SqlCeDataAdapter, dt As DataTable)
...
Dim cmd As SqlCeCommand = New SqlServerCe.SqlCeCommand
cmd.Connection = oSqlCEConn
cmd.IndexName="UK_IVCTAMOBILE"
cmd.CommandText="INSERT INTO IVCTAMOBILE(PKey,Status,Dfu,Lu,BusinessModified,BusinessModified_T,IvcTAMetaPKey,InitiationDate,IvcMainPKey,Accounted,Amount,SdoMainPKey,BpaMainPKey,PaymentMethod,InitiationDate_T) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
oSqlCEAdapter.InsertCommand=cmd
oSqlCEAdapter.Update(dt)
...
End Sub

I migrated the Database with this program:

Public Sub Upgrade(DB)
Dim sPath As String
Dim engine As System.Data.SqlServerCe.SqlCeEngine
sPath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
sPath = sPath.Substring(0, sPath.LastIndexOf(""))
engine = New System.Data.SqlServerCe.SqlCeEngine("Data Source=" & sPath & "Test.sdf")
engine.Upgrade()
MsgBox("Finished")
End Sub

Any ideas?

Thanks,
Stefan

View 12 Replies View Related

Create Session Model With Missing Value Parameter

Jan 28, 2008

Hi, I created a Session model via the following

CREATE SESSION MINING MODEL test
(
HCVS_MemberId Text KEY,
HCVS_MeasureDate_Float LONG KEY TIME,
HCVS_MeasureDate Date Discrete,
SysPressure LONG CONTINUOUS PREDICT,
DiaPressure LONG CONTINUOUS PREDICT,
Pluse LONG CONTINUOUS PREDICT
) USING Microsoft_Time_Series ;

How do I specify that I would like to Mean to fill the gap of missing values?

Thanks,
Ricky.

View 1 Replies View Related

Please Help Me 'DrillthroughSourceQuery' Parameter Is Missing A Value In Report Builder

May 30, 2007



Can u help to to solve my problem . Many time this question arised in the forum no one answer to me to find out the solution for my problem. So please help









I am using report builder thru LocalHostReport . I want a drill through report by using Report Builder and cube . I created the report but unfortunatly I cannot create a drill through report using parameters .How can I pass parameter in report1 to jump into report2 .



When I running the report after giving drill through properties in report the following error will occure.



'The 'DrillthroughSourceQuery' parameter is missing a value



How can I create a report using parameter for drill down in report builder







I am expecting one answer from u expertise

View 2 Replies View Related

How To Return All Records When Date Filter Parameter Is Missing

Mar 28, 2007

I'm using an objectDataSource connected to a strongly typed dataset to populate a GridView.  I want to be able to show all the records, or let the user to select only those records that expire in a certain month.  The expire field is of type date I'm used to all records being returned when a parameter is missing.  If I have Select * from table where last=@last, only the records where the last name is 'Smith' will be returned if @last = 'Smith', but all records are returned is @last = "".  But that's not how it's working with the date. I'm passing an integer from 1 to 12 in a querystring.  I have the equivalent of select * from table where (MONTH([AD ENDS]) = @month)MONTH(datefield) always returns an integer from 1 to 12.  If @month is empty, I want all the records to be displayed, but nothing is.  If @month is an int form 1 to 12, it works fine.  How can I get all the records if no month is selected?  Can I have two objectdatasources and programmatically select which one populates the gridview depending on if I want to filter the data or not?  Diane 

View 5 Replies View Related

Problem With ReportViewer In Local Mode (parameter Missing A Value)

Feb 16, 2006

Hi all...

I designed an rdlc file to be used with ReportViewer in an ASP.NET page.

The data source I used was an Object DataSource.

When I placed the ReportViewer control on the page, an ObjecrtDataSource control was added too. I configured it for the parameters the report will receive. The first string parameter is named PRO_DES, which has a default value of "" and the data come from request.Form.

When I run the report in the page, the following error appears:

The 'PRO_DES' parameter is missing a value

PRO_DES parameter, since it is a string, could be empty.

I tried to set a default value, but the same message appears.

DataSource is correctly attached to the report, so I don't know where the problem can be.

Any help will bne greatly appreciated

Thanks

Jaime

View 1 Replies View Related

Ordinal Question

Aug 29, 2006

Hi guys,

How to produce ordinal numbers in sql query?

Say I have a table for a Building. My floor numbers are intergers, 1,2,3,4 and so on. When I run the query, the result I need is like this:

1st
2nd
3rd
4th
5th
...
23rd
....

How will I do this?

Thank you.

View 17 Replies View Related

Ordinal Position

Jul 20, 2005

Is there a neat way to find an ordinal value from a table,for example the median or 95th percentile value in a column,without walking through the table in ascending or descendingorder?Thanks,Jim GeissmanCountrywide Home Loans

View 1 Replies View Related

Reporting Services :: Added Parameter In Report Builder Now Missing Query Results

Oct 30, 2015

So, this is my Query for dataset "SalesOrder":

SELECT
SO_Header.Customer
,SO_Header.Status
,SO_Header.Customer_PO
,Customer.Name
,SO_Header.Order_Taken_By

[Code] ...

I would like to have a parameter on my report to Select by Order_Taken_By. My attempt at that is here:

Dataset called OrderTaken:

select distinct SO_Header.Order_Taken_By
from SO_Header
Under the report Parameter Properties named @Order, under Available Values
Selected "Get Values from a query"

I have DataSet: OrderTaken

Value Field: Order_Taken_By
Label Field: Order_Taken_By

The values of the field Order_Taken_By is all text characters, no integer values.

Running the inital Query by itself yields results. When I add the parameter, I can make a selection, but now I get no results, even though there should be values for the choice I've chosen.

View 11 Replies View Related

Ordinal Number In Results

Jan 13, 2006

I would like to add a field to a query that returns an ordinal number indicating which row of the results it is. Anybuddy know how?
eg. 1,2,3,4,5,6,7....

Thanks,
Carl

View 2 Replies View Related

Sqlmangr.: The Ordinal 29 Could Not Be Located In

Apr 24, 2006

Dear all

I've received the following error on the startup of SQL SERVER. Repeating the error when trying to start Service Manager.

sqlmangr.exe : The ordinal 29 could not be located in the dynamic link library odbcbcp.dll

Can someone help me to solve it

View 1 Replies View Related

Fail SSDT Project Build When A Stored Procedure Call Missing Required Parameter?

Jun 17, 2015

Is it possible to force a build to fail when a stored procedure in a project calls another stored procedure with one or more required parameters missing. E.g.:
 
CREATE PROCEDURE [App].[ServiceUser_Save]
@userID int-- Param #0
,@serviceuserID int-- Param #1
,@version int-- Param #2 etc...

And then in a separate stored procedure we have the following

CREATE PROCEDURE [Admin].[CreateMiscellaneousData]
@customerIDint,
@serviceIDint,
@fullURL nvarchar(255),
@apiUserPwd nvarchar(255)
AS
BEGIN
...
EXEC@return_value = [App].[ServiceUser_Save]
@userID = 1,
@serviceuserID = 0, etc...

Note there is no value passed for the @Version parameter.

What I want is the build to fail because of the missing parameter on the call to ServiceUser_Save in the Create_MiscellaneousData stored procedure.

How can I achieve this?

View 4 Replies View Related

SQL Cliesnt Failing Ordinal 29 Not Correct..

May 3, 2004

Machine is Windows XP, Client is SQL2K . I tried rebooting without any luck. Uninstalled , reinstalled. After reboot when I try using SQL Clients (EM or QM) it returns the same errors regarding some Ordinal 29 and a big key from registry.. Please help

View 1 Replies View Related

Change Ordinal Position Of The Column

Jun 18, 2008

1 have a table with 74 colun.But due to some deletion i have the ordinal postions as
1
2
3
.
.
69
70
72
73
74
76

what i wants is to change the ordinal from 72 to 71,73 to 72,74 to 73,76 to 74

SELECT @field = 0, @maxfield = max(ORDINAL_POSITION) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TableName
-- handle insert case here
SELECT @field = min(ORDINAL_POSITION) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TableName and ORDINAL_POSITION > @field
SELECT @bit = (@field - 1 )% 8 + 1
SELECT @bit = power(2,@bit - 1)
SELECT @char = ((@field - 1) / 8) + 1
--IF substring(COLUMNS_UPDATED(),@char, 1) & @bit > 0 or @Type in ('I','D')
IF substring(COLUMNS_UPDATED(),@char, 1) & @bit > 0 or @Type in ('D') -- For the insertion case don't save the iserted data.


I needed it as i have a trigger whihc is adding value in a log table on update but due to this problem it fails for certain column

Trgger is solme thing like

WHILE @field < @maxfield
BEGIN
SELECT @field = min(ORDINAL_POSITION) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TableName and ORDINAL_POSITION > @field
SELECT @bit = (@field - 1 )% 8 + 1
SELECT @bit = power(2,@bit - 1)
SELECT @char = ((@field - 1) / 8) + 1
--IF substring(COLUMNS_UPDATED(),@char, 1) & @bit > 0 or @Type in ('I','D')
IF substring(COLUMNS_UPDATED(),@char, 1) & @bit > 0 or @Type in ('D') -- For the insertion case don't save the iserted data.
BEGIN
IF @Type not in ('I')
BEGIN
SELECT @fieldname = COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TableName and ORDINAL_POSITION = @field -1
--print('fieldname = '+@fieldname)
SELECT @sql = 'insert Audit (ActionTypeID, RowID, TableName, PK, FieldName, OldValue, NewValue, UpdateDate,UserID, UserName, UserType)'
SELECT @sql = @sql + ' select convert(bigint,' + @ActionTypeID + ')'
SELECT @sql = @sql + ',' + @RowID
SELECT @sql = @sql + ',''' + @TableName + ''''
SELECT @sql = @sql + ',' + @PKSelect
SELECT @sql = @sql + ',''' + @fieldname + ''''
SELECT @sql = @sql + ',convert(varchar(1000),d.' + @fieldname + ')'
SELECT @sql = @sql + ',convert(varchar(1000),i.' + @fieldname + ')'
SELECT @sql = @sql + ',''' + @UpdateDate + ''''
SELECT @sql = @sql + ',' + @UserID
SELECT @sql = @sql + ',''' + @UserName + ''''
SELECT @sql = @sql + ',''' + @UserType + ''''
SELECT @sql = @sql + ' from #ins i full outer join #del d'
SELECT @sql = @sql + @PKCols
SELECT @sql = @sql + ' where i.' + @fieldname + ' <> d.' + @fieldname
SELECT @sql = @sql + ' or (i.' + @fieldname + ' is null and d.' + @fieldname + ' is not null)'
SELECT @sql = @sql + ' or (i.' + @fieldname + ' is not null and d.' + @fieldname + ' is null)'
--print('@sq=====sdfdfsfsdf')--sha
--print(@sql)--sha
EXEC (@sql)
END
END
END

Kamran Shahid
Sr. Software Engineer(MCSD.Net)
www.netprosys.com

View 9 Replies View Related

Need Help With ExecuteReader() Command

Jan 18, 2008

HI I am having problem with my Execute Reader. I am trying to insert values from 2 different tables into another table.    SqlCommand comm2; SqlDataReader reader2; /* Grabs the stuff out of the database */
comm2 = new SqlCommand("SELECT HiraganaCharacter,HiraganaImage FROM Hiragana", getConnection()); /* opens the database */
comm2.Connection.Open();
/* starts the reader */
reader2 = comm2.ExecuteReader();
/* goes through the first array list */
for (int i = 0; i < checkedLetters.Count; i++) { /* find the data by using the array list value as a where clause */ comm2.CommandText = "SELECT HiraganaCharacter,HiraganaImage FROM Hiragana WHERE HiraganaCharacter ='"
+ checkedLetters[i] + "'"; /* reads through the data */ reader2.Read(); /* puts the ID- this id was set somewhere else */ CommQuickLinksItems.Parameters["@QuickLinkID"].Value = QuickLinkId; CommQuickLinksItems.Parameters["@CharacterName"].Value = reader2["HiraganaCharacter"].ToString(); CommQuickLinksItems.Parameters["@CharacterImagePath"].Value = reader2["HiraganaImage"].ToString(); CommQuickLinksItems.ExecuteNonQuery(); } for (int j = 0; j < checkedLettersKata.Count; j++) { comm2.CommandText = "SELECT KatakanaCharacter,KatakanaImage FROM Katakana WHERE KatakanaCharacter ='"
+ checkedLettersKata[j] + "'"; reader2.Read(); CommQuickLinksItems.Parameters["@QuickLinkID"].Value = QuickLinkId; /* line it dies on */ CommQuickLinksItems.Parameters["@CharacterName"].Value = reader2["KatakanaCharacter"].ToString(); CommQuickLinksItems.Parameters["@CharacterImagePath"].Value = reader2["KatakanaImage"].ToString(); CommQuickLinksItems.ExecuteNonQuery(); } CommQuickLinksItems.Connection.Dispose(); CommQuickLinksItems.Dispose(); comm2.Connection.Dispose(); comm2.Dispose(); My first question is there a better way to setup a SqlCommand to just get the connection and wait on the Command object text? Right now I am doing comm2 = new SqlCommand("SELECT HiraganaCharacter,HiraganaImage FROM Hiragana", getConnection());Which is kinda pointless since in the for loop I change the command to something different right away. At the same time though I don't really want to make a new SqlCommand object in the for loop since then everytime it goes through the loop it would then re grab the connection what I find pointless tooNow the problem How I have it right now it does not grab the right stuff. The first for loop works great and everything gets inserted. The next loop does not work It seems like it it trying to take the data from the first for loop and insert that stuff again since I get this error System.IndexOutOfRangeException was unhandled by user code Message="KatakanaCharacter" Source="System.Data" StackTrace: at System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) at System.Data.SqlClient.SqlDataReader.get_Item(String name) at Practice.QuickLinks() in g:WebsiteJapanesePractice.aspx.cs:line 385 at Practice.btnQuickLink_Click(Object sender, EventArgs e) in g:WebsiteJapanesePractice.aspx.cs:line 411 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException: Basically what I did was for the first loop I chose 2 items and for the 2nd loop I chose 3 items. When it died on this line  CommQuickLinksItems.Parameters["@CharacterName"].Value = reader2["KatakanaCharacter"].ToString();The value was "i" but that was one of the values I choose for the first for loop. It should have been either u,e,o. So I am not sure what I am doing wrong. I thought as long as I change the Command text I would not need to do anything else but it seems like I am missing something.  

View 5 Replies View Related







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