DeadLock Occur While Execute SqlDataAdapter.Fill Method

Mar 25, 2008

Hi,

I am using  following code to fill my dataset. when multiple user connect to the web-site it will give me following error:

Error Message: Transaction (Process ID 98) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

I am using stored procedure to select records from database.

DataSet ds = new DataSet();SqlConnection mc = OpenSqlConnection();

try

{SqlCommand cmd = new SqlCommand(strCmd, mc);cmd.CommandType = CommandType.StoredProcedure;

cmd.CommandTimeout = 0;if (parameters != null)

{foreach (KeyValuePair<string, object> p in parameters)

{

cmd.Parameters.AddWithValue(p.Key, p.Value);

}



}SqlDataAdapter da = new SqlDataAdapter(cmd);

da.Fill(ds);

}catch (Exception ex)

{

}

finally

{

mc.Close();

}

return ds;

 

Appreciate your help,

prashant

View 1 Replies


ADVERTISEMENT

What Happened To Nice SqlDataAdapter.Fill Method In ASP.net 2.0

Dec 26, 2005

What happened to nice SqlDataAdapter.Fill method in ASP.net 2.0 + How can i now access and traverse trhough table.
ex : sqlDataAdapter.Fill(dataSetname.tblsname);
            dataSet11.rows[][]

View 5 Replies View Related

Arithmetic Overflow Error Converting Expression To Data Type Int When Using Fill From A SqlDataAdapter

Mar 7, 2007

I thought I'd post this quick problem and answer, as I couldn't find the answer when searching for it. 
I tried to call a stored procedure on SQL Server 2000 using the System.Data.SqlClient objects, and was not expecting any unusual issues.  However when I came to call the Fill method I received the error "Arithmetic overflow error converting expression to data type int."
My first checks were the obvious ones of verifying that I'd provided all the correct datatypes and had no unexpected null values, but I found nothing out of order.  The problem turns out to be a difference on the maximum values for integers between C# and SQL Server 2000.  Previously having hit issues with SQL Server integers requiring Long Integer types in VB6, I was aware that these are 32-bit integers, so I was passing in Int32 variables.  The problem was that Int32.MaxValue is not a valid integer for SQL Server.  Seeing as I was providing an abitrary upper value for records-per-page (to fetch all in one page), I was simply able to change this to Int16.MaxValue and will hit no further problems as this is also well beyond any expected range for this parameter.
 If anyone can name off the top of their heads what value should be provided as a maximum integer for SQL Server 2000, this might be a useful addition, but otherwise I hope this spares others some hunting if they also experience this problem.
James Burton

View 1 Replies View Related

How Can I Re-install The Northwind Database In SQL Server Management Studio Express?Use SqlDataSet &&amp; The .Fill Method Properly?

Apr 30, 2007

Hi all,

In my VB 2005 Express, I created a Windowds Form application "shcDataSet" that used 1 SqlConnection, 1 SqlDataSet and 3 SqlDataAdapters associated with the Northwind Database in my SQL Server Management Studio Express. The SqlConnection had "User Instance" in the following ConnectionString: Data Source=.SQLEXPRESS;AttachDbFilename="C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataorthwnd.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True. The 3 SqlDataAdapters were for the Northwind files "Customers", "Orders" and "Order Details" used in the SQLDataSet "AllOrders" with a AllOrders.xsd file. I ran the "shcDataSet" applicatyion and it worked fine. After the execution of "shcDataSet", I checked the Northwind database in my SQL Server Management Studio Express and clicked on "+" in front of Northwind database-I did not see any file showed up and I got the following error message: Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum) Additional information: one or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. (Microsoft SQL Server, Error:5173). If I executed the "shcDataSet" application again, I got a new error: SqlException was unhandled - Cannot open user default database. Login failed. Login failed for user 'myPC##myName' ------->daCustomers.Fill(AllOrders11, "Customers"). I have 3 questions to ask: (1) How can I re-install the Northwind database in SQL Server Management Studio Express? (2) When I use the .Fill Method, do I have to tell the SQL Server Management Studio Express to load and/or unload the Northwind files "Customers", "Orders" and "Order Details"? (3) After I executed the "shcDataSet", should I Upload the 3 Northwind files back to the SQL Server Management Studio Express? Please help and advise. Thanks, Scott Chang

View 7 Replies View Related

Error With Execute Sql Task And Full Result Set: Not Been Initialized Before Calling 'Fill'

Oct 10, 2006

This is the first time I've tried creating an "execute sql task" with a "full result set".

I've read in the documentation that I must set the resultname to 0, which is done, and that the variable must be of type object. Also done.

[Execute SQL Task] Error: Executing the query "select * from blah" failed with the following error: "The SelectCommand property has not been initialized before calling 'Fill'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Has anyone else had success with a full result set?

Thanks,
-Lori

View 10 Replies View Related

Package.Execute() Method Error

Jan 9, 2008



Hi,

I have a strange problem with calling packages from c# code. Packages start to execute, but never finish. Instead an error occures in eventlog:

(message is translated into english so it can sound a bit different)


Erring application AppName.exe, version 1.0.0.0, timestamp 0x4784c811, erring module ntdll.dll, version 6.0.6000.16386, timestamp 0x4549d372, exception code 0xc0000374, error shift 0x00000000000c87b7, process ID 0x1284, application start time 0x01c852ceb26bbad3.

In debuger, execution stoppes on line "DTSExecResult res = dtsPkg.Execute();", but no error is showed.

This behaviour occured unexpectally. Application worked correctly and in a minute I wasn´t able to execute any package from an application. I also tryed it from another computer and got the same error. Calling packages directly from management studio works fine.

OS:
Windows Vista Bussiness 64b

Code:

Package dtsPkg = new Package();

Variables variables = dtsPkg.Variables;

Microsoft.SqlServer.Dts.Runtime.Application dtsApp = new Microsoft.SqlServer.Dts.Runtime.Application();

dtsPkg = dtsApp.LoadFromSqlServer(@"\PackageName", "server", null, null, null);

dtsPkg.InteractiveMode = true;

dtsPkg.DebugMode = true;

dtsPkg.LoggingMode = DTSLoggingMode.Enabled;


dtsPkg.VariableDispenser.LockOneForWrite("FilePath", ref variables);

Variable pathVar = variables[0];

pathVar.Value = filePath;

variables.Unlock();

DTSExecResult res = dtsPkg.Execute();



I will be grateful for any ideas

Janca

View 8 Replies View Related

Post Execute Method Not Being Called - LockReadWriteVariables

Jul 22, 2007

I have a strange bug when trying to run SSIS. I get the message in the output window "

Information: 0x40043008 at Data Flow Task, DTS.Pipeline: Post Execute phase is beginning. " in a script component but the Post Execute method is not being called.

I have placed a firewarning as the first statement to try and debug that the procedure is being called but to no avail as it is not being output

Has anyone come across this kind of issue before or have any suggestion on how to proceed ?



After a long period of time I then got the following messge displayed



at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariableDispenser90.GetVariables(IDTSVariables90& ppVariables)

at Microsoft.SqlServer.Dts.Pipeline.ScriptComponent.LockReadWriteVariables(String readWriteVariables)

at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PostExecute()



Within the package I have two script components one that uses a readwrite variable to set the variable to be a date in the first script tasks PostExecute and then the second component uses the date variable in its PostExecute method. Running the package seemd to imply that the first postexecute write t the variable is somehow locking out the next component from reading the variable.

View 3 Replies View Related

Script Component And Post Execute Method - Help Please!

May 7, 2008











Hello, I have been wrestling with a script component and the post execute method. I have obtained some bits of information from the discussions from previous posting - http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=97494&SiteID=1 and have also tried the suggested approaches. Being new to SSIS and .NET as well I am certain that I do not see the entire picture yet.

I have a Read/Write variable that I am assigning a value to. The variable is then processed through a derived column and subsequently used by a flat file.

I have eliminated the following exception thus far.

Error: 0xC0047062 at Data Flow Task, Script Component [518]: Microsoft.SqlServer.Dts.Pipeline.ReadWriteVariablesNotAvailableException: The collection of variables locked for read and write access is not available outside of PostExecute.

But, my flat file does not contain in it the assigned values to the variable. A brief summary of the process follows:


OLE DB SOURCE ===> followed by the Script Component ===> followed by the Derived Columns ===> followed by the flat file.

Sample Script is:

Public Class ScriptMain
Inherits UserComponent

Public NewName As String

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
'
' Add your code here
'
NewName = Row.BPNM

Me.Variables.ShortName = NewName

End Sub

Public Overrides Sub PostExecute()

MsgBox("In first script...")
Me.Variables.ShortName = NewName
MsgBox("variable is " & Me.Variables.ShortName)
End Sub


Question. What am I not doing that prevents me from extracting and passing the respective values to the derived column for each of the rows processed. When I try to assign the value of NewName to the Short Name variable, In red above, I encounter the post execute exception, again.

What code should I have in place to insure that I am not trying to reference the variable on a PostExecute within the normal process of the script component? Any guidance would be immensly appreciated.

Help Please!!

View 11 Replies View Related

Best Method For Using FTP Command Xp_cmdshell Or Execute Process Task

Dec 8, 2005

Hi, I need to send a table data into flat and then ftp into different location.
I was using xp_cmdshell via sql task but my network engineer is saying that this xp_cmdshell will break the security and recomond to use "Execute Process Task". If i'm using this task getting the below error.
Could you advice me regrding network engineer thought and any solution for avoiding this error.


---------------------------
Execute Process Task: C:WINDOWSsystem32ftp.exe
---------------------------
CreateProcessTask 'DTSTask_DTSCreateProcessTask_1': Process returned code 2, which does not match the specified SuccessReturnCode of 0.
---------------------------
Thanks,

View 1 Replies View Related

Ho To Make Data Source Web Method Execute Once Per A Report?

Jan 11, 2007

My report works with XMLDP data provider and obtains source data as a
result of a web method call. This memthod returns all data necessary
for the report. Thus, all of about 20 report datasets query the same
web method with the same parameters and then select appropriate data
with different ElementPath expressions. It's so inefficient and
time-consuming! I cant have respective web method for every dataset.
How can I configure SSRS to call web method only once while the report
is executing? Or how can I leverage the performance at all?

View 1 Replies View Related

EXECUTE Permission Denied On Object Sp_OACreate/method/GetProperty/Destroy

Aug 3, 2002

Hi friends

I copy script that use SQL proc to call DTS package from this site.

When I run this procedure in SQL query alalyzer. I got an error messages:
EXECUTE permission denied on object sp_OACreate/method/GetProperty/Destroy.
I did not change anything in spExecutePKG.
Even I used sa as ServerPWD. How to fix this problem? my code is
exec spExecutePKG 'myserver','execl_DTS','sa','0',''
Thanks
jimmy

------proc original code
CREATE PROC spExecutePKG
@Server varchar(255),
@PkgName varchar(255), -- Package Name (Defaults to most recent version)
@ServerPWD varchar(255) = Null,-- Server Password if using SQL Security to load Package (UID is SUSER_NAME())
@IntSecurity bit = 0,-- 0 = SQL Server Security, 1 = Integrated Security
@PkgPWD varchar(255) = ''-- Package Password
AS
SET NOCOUNT ON
/*
Return Values
- 0 Successfull execution of Package
- 1 OLE Error
- 9 Failure of Package
*/
DECLARE @hr int, @ret int, @oPKG int, @Cmd varchar(1000)

-- Create a Pkg Object
EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUTPUT
IF @hr <> 0
BEGIN
PRINT '*** Create Package object failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN 1
END

-- Evaluate Security and Build LoadFromSQLServer Statement
IF @IntSecurity = 0
SET @Cmd = 'LoadFromSQLServer("' + @Server +'", "' + SUSER_SNAME() + '", "' + @ServerPWD + '", 0, "' + @PkgPWD + '", , , "' + @PkgName + '")'
ELSE
SET @Cmd = 'LoadFromSQLServer("' + @Server +'", "", "", 256, "' + @PkgPWD + '", , , "' + @PkgName + '")'

EXEC @hr = sp_OAMethod @oPKG, @Cmd, NULL

IF @hr <> 0
BEGIN
PRINT '*** LoadFromSQLServer failed'
EXEC sp_displayoaerrorinfo @oPKG , @hr
RETURN 1
END

-- Execute Pkg
EXEC @hr = sp_OAMethod @oPKG, 'Execute'
IF @hr <> 0
BEGIN
PRINT '*** Execute failed'
EXEC sp_displayoaerrorinfo @oPKG , @hr
RETURN 1
END

-- Check Pkg Errors
EXEC @ret=spDisplayPkgErrors @oPKG

-- Unitialize the Pkg
EXEC @hr = sp_OAMethod @oPKG, 'UnInitialize'
IF @hr <> 0
BEGIN
PRINT '*** UnInitialize failed'
EXEC sp_displayoaerrorinfo @oPKG , @hr
RETURN 1
END

-- Clean Up
EXEC @hr = sp_OADestroy @oPKG
IF @hr <> 0
BEGIN
EXEC sp_displayoaerrorinfo @oPKG , @hr
RETURN 1
END

RETURN @ret
GO

View 1 Replies View Related

Pre-Execute AcquireConnection Method Call Fails Inside Sequence Container (transaction Required)

Jun 1, 2006

I've created an SSIS package that contains a Sequence Container with TransactionOption = Required. Within the container, there are a number of Execute Package Task components running in a serial fashion which are responsible for performing "Upserts" to dimension and fact tables on our production server. The destination db configuration is loaded into each of these packages using an XML configuration file. The structure of these "Upsert" packages are nearly identical, while some execute correctly and others fail. Those that fail all provide the same error messages.

These messages appear during Pre-Execute

[Insert new dimension record [1627]] Error: The AcquireConnection method call to the connection manager "DW" failed with error code 0xC0202009.

[DTS.Pipeline] Error: component "Insert new dimension record" (1627) failed the pre-execute phase and returned error code 0xC020801C.

... which are followed by

[Connection manager "DW"] Error: The SSIS Runtime has failed to enlist the OLE DB connection in a distributed transaction with error 0x8004D00A "Unable to enlist in the transaction.".

[Connection manager "DW"] Error: An OLE DB error has occurred. Error code: 0x8004D00A.

While still in debug mode, I can check the properties of the "DW" connection and successfully test the connection within the packages that fail.

The same packages run successfully when tested outside the container (i.e. no transaction) or when the configuration file is modified to point the "DW" connection to a development version of the db which is running on the same server as the source database.

I have successfully used DTCtester to verify that transactions from source to destination server are working correctly. Also tried setting DelayValidation = True with no change. I have opened a case with Microsoft and am awaiting a reply so I thought I'd throw a post out here to see if anyone else has encountered this and might have a resolution. Here's some more on the environment:

Source Server:

Windows Server 2003 Enterprise Edition SP1
SQL Server 2005 Enterprise Edition SP0

Destination Server:

Windows Server 2003 Enterprise Edition SP1
SQL Server 2000 Enterprise Edition SP3 (clustered)

Thank you in advance for any feedback you might be able to provide.

KS

View 4 Replies View Related

Mirroring :: Email Deadlock Information When A Deadlock Occurs

Nov 10, 2015

Is there a way to send out an email woth deadlock information (victim query, winner query, process id's and resources on which the deadlock occurred) as soon as a deadlock occurs in a database or at instance level?I currently has trace flag 1222 turned on. And also created an alert that send me an email whenever a deadlock occurs. but it just says that a deadlock occurred and I log into sql server error log and review the information.

View 5 Replies View Related

List When Changes Occur

Jul 20, 2005

Hi I am a newbie to SQL.I have a historical list of digatal points listed by time.ie: 3 fieldsPointName;Date/Time;State.I need to return a list of When a specific point chsnges state.For example a list everytime Point A transitions to State 1.Any help is appreciated.--Posted via http://dbforums.com

View 1 Replies View Related

Handling Failover Occur Using T-SQL

May 10, 2007

Hi all,



With C# or VC++ we can use ADO.NET that support the system work smothly when failover occur. I would like to handle failover in t-sql enviroment and it seam to be hard for me when swiching ":connect <servername> code



Do you have any idea to handle it with T-SQL. I need to make a demo on it. Please help!

View 1 Replies View Related

Send Request To Stored Procedure From A Method And Receive The Resposne Back To The Method

May 10, 2007

Hi,I am trying to write a method which needs to call a stored procedure and then needs to get the response of the stored procedure back to the variable i declared in the method. private string GetFromCode(string strWebVersionFromCode, string strWebVersionString)    {      //call stored procedure  } strWebVersionFromCode = GetFromCode(strFromCode, "web_version"); // is the var which will store the response.how should I do this?Please assist.  

View 3 Replies View Related

Deleting Duplicates Which Occur In Only One Column

Aug 9, 2006

Hello all. I have a table with two coulmns CODE and DESCRITPION. Can anyone suggest how i can go about deleteing the entire record where two or more codes are the same?

Thanks.

View 4 Replies View Related

Conflicts Consistently Occur On Merge

Aug 15, 2007

Hi,

I was hoping a sharp eye may be able to pick up on what I am doing wrong here, I am i must be making a comon mistake. If necessary I am happy to create and post a sample if necessary.

Problem:
The publication parent table has a filter (defined below) and also has a join filter(defined below) to a child table. When changes are made to the parent and child table and synchronised a conflict is raised. For the child table for some reason the merge agent is saying an explicit update occured at the publisher but the values at the publisher have not changed at all and no sql has been executed to update the publisher rows. This in effect is stopping the changes to the child table being applied until i manually apply them in the conflict resolver. The strange thing is the conflict should not occur in the first place.

Perhaps my SQL server 2005 version? 9.00.2050.00 SP1 Standard Edition

Environment:

SQL Server 2005 - 9.00.2050.00 SP1 Standard Edition
SQL Server Mobile
Detail:


FKs are


FK: Job.JobScheduleID --> JobSchedule.ID

FK: JobDetail.JobID --> Job.ID

All three tables have int based IDs that are auto increment.

Publication Articles:


JobSchedule is download only

Job is Bidirectional, identity range management is MANUAL (only updates occur on this table)

JobDetail is Bidirectional, identity range management is MANUAL (only updates occur on this table)

Filters are of the following form:


Filter Job:




SELECT <published_columns> FROM [dbo].[Job] WHERE convert(nchar,[companyID])=Host_Name() AND [JobCompletedDate] IS NULL AND

( [JobScheduleID] in (SELECT distinct ID from JobSchedule where GETDATE() BETWEEN [JobSchedule].[start] AND [JobSchedule].[end]) )



Join Filter Job --> JobDetail




SELECT <published_columns> FROM [dbo].[Job] INNER JOIN [dbo].[JobDetail] ON [Job].[ID] = [JobDetail].[JobID]
Now the first thing to note with respect to using GetDate() i have read http://msdn2.microsoft.com/en-us/library/ms365153.aspx so i thought that i would remove that portion of the Filter on the Job table just to see what happens.

SELECT <published_columns> FROM [dbo].[Job] WHERE convert(nchar,[companyID])=Host_Name() AND [JobCompletedDate] IS NULL

This still did not resolve the issue. I then Remove the AND [JobCompletedDate] IS NULL and it then started working fine (cool) but of course no longer satisfys the rule i want to create (seriously uncool ).

Any ideas out there ?

Much appreciated,
pdns

View 6 Replies View Related

Bcp Error: Truncation Cannot Occur For BCP Output File

Jul 17, 2007

Hi,

I'm trying to export sql table as fixed length text file with format file but I got the following error message:







Error = [Microsoft][ODBC SQL Server Driver][SQL Server]
Warning: Server data (61 bytes) exceeds host-file field length (60 bytes) for field (4).
Use prefix length, termination string, or a larger host-file field size.
Truncation cannot occur for BCP output file







All fields in the SQL input table have char data type and I use the format file like this:







7.0
29
1 SQLCHAR 0 10 "" 1 SEQ
2 SQLCHAR 0 1 "" 2 NPARSED
3 SQLCHAR 0 115 "" 3 COMPANY
4 SQLCHAR 0 60 "" 4 ADDR1
....
27 SQLCHAR 0 1 "" 27 LACS
28 SQLCHAR 0 2 "" 28 DPV
29 SQLCHAR 0 2 "
" 29 ZIP4CODE







I've been researched about this error but I couldn't find the clear answer.

The strange thing is that all the records are char() fields, not varchar()

And I checked the max length record for the 4th column(ADDR1) and it was 60, not 61.

However I'm still getting the error.

The output file was exported but some of the records have short length.

Is this some kind of bcp bug?

I used SQL Server 2000 Standard w/ SP4

And the following is the command that I used:







declare @cmd varchar(2000)

SET @cmd = 'bcp "Input_table" out "D:AddressUpdateTmpxFixADDR.dat" -fD:AddressUpdateTmpxFixADDR.fmt -Usa -Psapass -SMyMachine''
print(@cmd)
EXEC master..xp_cmdshell @cmd







Please let me know if anyone solve the similar problem.

Thanks,

- Hyung -

View 3 Replies View Related

Error Occur While Delete Large Volum Records

Jan 6, 2004

I had write a ActiveX service to delete several tables and those records are more than 100000. When I test it by deleted 1000 records it is ok, but once the volum is increase until 100000, it will give me a error message said timeout operation fail.

how can i overcome this problem. please!!!!

View 8 Replies View Related

Transport-level Errors Occur After Adding New IP Address

Apr 30, 2008

We get this error when we add IP addresses to the Windows system when SQL 2005
database activity is on-going:


Database error: A transport-level error has occurred when receiving results
from the server. (provider: TCP Provider, error: 0 - The semaphore timeout
period has expired.)


.NET application can be running for weeks without error, but after adding a
new IP address, application gets 5-16 'transport-level errors' before
correcting itself.



Error occurs on Windows XP computer in our case. SQL Server, running on Windows server 2003, doesn't seem to pick up on the newly added IP address.

View 12 Replies View Related

Update Method Is Not Finding A Nongeneric Method!!! Please Help

Jan 29, 2008

Hi,
 I just have a Dataset with my tables and thats it
 I have a grid view with several datas on it
no problem to get the data or insert but as soon as I try to delete or update some records the local machine through the same error
Unable to find nongeneric method...
I've try to create an Update query into my table adapters but still not working with this one
Also, try to remove the original_{0} and got the same error...
 Please help if anyone has a solution
 
Thanks

View 7 Replies View Related

Where Does The Problem Occur? System.Data.SqlClient.SqlException: Timeout Expired.

Jan 19, 2008

Hi, I work in a hosting company and one of the customer's has the following error listed in the event viewer, they have asked us to look into the problem as the web server is showing the error and they suspect it is a connection problem to the database. From a windows OS point of view I cannot find anything that could be causing this.  Could someone confirm that this looks like and app/coding issue rather than an OS issue??  System.Data.SqlClient.SqlException: Timeout expired.  The timeout periodelapsed prior to completion of the operation or the server is notresponding.--------------------------------------------------------------------DEBUG INFOUnable to connect to SQL Server session database.   Timeout expired.  The timeout period elapsed prior to completion ofthe operation or the server is not responding.--------------------------------------------------------------------BASE EXCEPTION TOSTRINGSystem.Data.SqlClient.SqlException: Timeout expired.  The timeout periodelapsed prior to completion of the operation or the server is notresponding.   at System.Data.SqlClient.SqlConnection.OnError(SqlExceptionexception, Boolean breakConnection)   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlExceptionexception, Boolean breakConnection)   atSystem.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSetbulkCopyHandler, TdsParserStateObject stateObj)   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()   at System.Data.SqlClient.SqlDataReader.get_MetaData()   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReaderds, RunBehavior runBehavior, String resetOptionsString)   atSystem.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, Booleanasync)   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, Stringmethod, DbAsyncResult result)   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, Stringmethod)   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehaviorbehavior, String method)   at System.Data.SqlClient.SqlCommand.ExecuteReader()   at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContextcontext, String id, Boolean getExclusive, Boolean& locked, TimeSpan&lockAge, Object& lockId, SessionStateActions& actionFlags)--------------------------------------------------------------------STACKTRACE   at System.Data.SqlClient.SqlConnection.OnError(SqlExceptionexception, Boolean breakConnection)   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlExceptionexception, Boolean breakConnection)   atSystem.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSetbulkCopyHandler, TdsParserStateObject stateObj)   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()   at System.Data.SqlClient.SqlDataReader.get_MetaData()   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReaderds, RunBehavior runBehavior, String resetOptionsString)   atSystem.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, Booleanasync)   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, Stringmethod, DbAsyncResult result)   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, Stringmethod)   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehaviorbehavior, String method)   at System.Data.SqlClient.SqlCommand.ExecuteReader()   at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContextcontext, String id, Boolean getExclusive, Boolean& locked, TimeSpan&lockAge, Object& lockId, SessionStateActions& actionFlags)

View 1 Replies View Related

Sqldataadapter

Sep 30, 2007

hi
it looks like my thread has been deleted but I keep on asking.
When trying to connect to a table i a SQL2005 database in a vb.Net webapplication I get the following error message from the wizard:
"The wizard detected the following errors when configuring the data adapter "SqlDataAdapter1".

"Check" Generated SELECT Statement
"Check" Generated Mappings
"Warning" Generated INSERT Statement
There were errors configuring the data adapter
"Warning" Generated UPDATE Statement
There were errors configuring the data adapter
"Warning" Generated DELETE Statement
There were errors configuring the data adapter"

The same connection works fine in a vb6 application. I have seen other threads concerning this in this forum but I can't find any answers. Any ideas anyone?
ciao chris

View 2 Replies View Related

Inherits SqlDataAdapter

Aug 16, 2006

Hi guys. Does anybody have any clue about how to create a class which inherits from SqlDataAdapter? I tried but looks like SqlDataAdapter is not inheritable. I would like to extend it with some custom method such as a method which fills a Dataset (used with a DataGrid) with the only few records to display per page (say 20) against the thousand records it might instead contain otherwise.Any workarounds? Many thanks in advance for your help.

View 1 Replies View Related

SqlDataAdapter && SqlParameter

Mar 26, 2007

Hi I am writing an app in flash which needs to hook up to MS SQL via asp.I need the code below to pass the var (ptodaysDate) to the sql statement. I can hard code it in and it works great but I really need to pass the var from flash.Pulling my hair out here, not much left to go.Any help greatly appreciated.----------------------------------------------    [WebMethod]    public Schedule[] getSchedule(int ptodaysDate)    {                SqlDataAdapter adpt =            new SqlDataAdapter("SELECT scheduleID, roomName, eventType,unitName,groupName,staffName,staffName2,theDate,theEnd FROM tb_schedule Where theDate >= @rtodaysDate", connString);        SqlParameter rtodaysDate = new SqlParameter("@rtodaysDate", ptodaysDate);               DataSet ds = new DataSet();        ArrayList al = new ArrayList();        adpt.Fill(ds);        foreach (DataRow row in ds.Tables[0].Rows)        {            Schedule obj = new Schedule();            obj.scheduleID = (int)row["scheduleID"];            obj.roomName = (string)row["roomName"];            obj.eventType = (string)row["eventType"];            obj.unitName = (string)row["unitName"];             obj.groupName = (string)row["groupName"];             obj.staffName = (string)row["staffName"];            obj.staffName2 = (string)row["staffName2"];            obj.theDate = (string)row["theDate"];            obj.theEnd = (string)row["theEnd"];            al.Add(obj);        }        Schedule[] outArray = (Schedule[])al.ToArray(typeof(Schedule));        return outArray;    }    public class Schedule    {        public int scheduleID;        public string roomName;        public string eventType;        public string unitName;        public string groupName;        public string staffName;        public string staffName2;        public string theDate;        public string theEnd;           }

View 2 Replies View Related

How Do I Reuse A SqlDataAdapter

Apr 25, 2007

It's a pretty basic question but I haven't been able to find any examples out there.  I dimmed a dataadapter and would like to reuse later in my code (line 3 in the code below).  What is the correct syntax to do this? Dim da As New SqlDataAdapter("SELECT * FROM myTable", conn)da.Fill(myDataTable)da.______  ("SELECT * FROM myTable2", conn)da.Fill(myDataTable2) 

View 2 Replies View Related

Problems With SqlDataAdapter

Aug 15, 2007

I'm working on a project to dynamically create PDFs with content from an SQL server. My current approach is to get the data I need into a DataSet using SqlDataAdapter, write the DataSet to a stream as XML, transform the XML into FO and then output a pdf using FOP. For some reason I get the following exception "System.NullReferenceException - Object reference not set to an instance of an object" when I try to set the SelectCommand property of my data adapter. Code for the project follows:Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        Dim con As SqlConnection        Dim cmd As SqlCommand        Dim IDlist As String        Dim keyidary As Array        Dim query As String        Dim tempxml As Stream        query = "*****query is valid and very long, so it's not included here*****"        IDlist = Request.Form("chosenIDs")        keyidary = Split(IDlist, ",")        Dim makequery As New StringBuilder(query)        For Each ID As String In keyidary            makequery.Append(" OR (KeyID = '" & ID & "')")        Next        query = makequery.ToString()        'Response.Write(query)         When uncommented this prints the query just fine        'Response.End()        Try            con = New SqlConnection            con.ConnectionString = "****Connection String is valid****"            cmd = New SqlCommand            cmd.CommandText = query            cmd.CommandType = CommandType.Text            cmd.Connection = con            Dim adpt As SqlDataAdapter            adpt.SelectCommand = cmd            'Response.Write(query)          When these are above or between the previous 2 statements, query is printed,            'Response.End()                     otherwise I get the error described above.            Dim profiles As New DataSet            adpt.Fill(profiles)            profiles.WriteXml(tempxml)            Dim step1 As XslTransform = New XslTransform            Dim step2 As XslTransform = New XslTransform            step1.Load(Server.MapPath("TransAttmpt1.xslt"))            step2.Load(Server.MapPath("formatXML.xsl"))            Dim xml, pdf As String            xml = "profiles.xml"            pdf = "Profiles.pdf"            Dim temp2xml As New XPathDocument(tempxml)            Response.Write(query)            Response.End()            Dim midstream As Stream            Dim finalxml As StreamWriter = New StreamWriter(xml)            step1.Transform(temp2xml, Nothing, midstream, Nothing)            Dim xpathdoc2 As XPathDocument = New XPathDocument(midstream)            step2.Transform(xpathdoc2, Nothing, finalxml, Nothing)            GeneratePDF(xml, pdf)        'There's a lot more but it doesn't seem relevant now.... I'm somewhat at a loss on how to proceed and any help is very greatly appreciated.Thanks! 

View 2 Replies View Related

SqlDataAdapter Update

Oct 1, 2007

Hi all,
I have datatable having around 50 rows and 3 columns ID, Name and ExpVal, which is an expression columns,where the values can be any SQL functions Like REPLICATE(), SOUNDEX ( 'value' ) Or REVERSE ( 'value' ).....
i want to insert each row in that datatable like
INSERT INTO TAB1 ( ID, Name, ExpVal) VALUES (1, 'some name', SOUNDEX ( 'some name' ) )
so that the ExpVal will have value of the function ie inserted row look like
ID  Name            ExpVal1   some name    S500 <--- Result of SOUNDEX ( 'some name' )
I'm using sqldatadapter to insert these values to the database
string sql = "INSERT INTO TAB1 (ID, Name, ExpVal)VALUES (@ID, @Name, @ExpVal) ";SqlDataAdapter sqlAdptr = new SqlDataAdapter();SqlCommand sqlCmd = new SqlCommand(sql, con);sqlCmd.parameters.Add("@ID", SqlDbType.Int, 0, "ID");sqlCmd.parameters.Add("@Name", SqlDbType.NVarChar, 200, "Name");sqlCmd.parameters.Add("@ExpVal", SqlDbType.VarChar, 100, "ExpVal");sqlAdptr.InsertCommand = sqlCmd;sqlAdptr.Update(dataTable);
This works fine, but the problem is, now the TAB1 contains
ID  Name            ExpVal1   some name   'SOUNDEX ( 'some name' )' instead of S500
Thatis the sql funtion is passed by SqlDataAdapter to database as a string and it is not executing while row is inserted to the table.Please provide what changes i have to make if i want SOUNDEX ( 'some name' ) to executed while data insertion take place
Thanks in advance

View 1 Replies View Related

SqlDataAdapter And DataSet

Jun 3, 2008

I'm getting a strange error with my dataadapter.  Here's my code:  using (SqlConnection conn = new SqlConnection(
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
SqlDataAdapter da = new SqlDataAdapter("sprocCUSTOM", conn);
da.SelectCommand.Parameters.AddWithValue("@eventID", EventID);

conn.Open(); //open connection
DataSet ds = new DataSet();
da.Fill(ds);
gvAttendees.DataSource = ds;
gvAttendees.DataBind();
}This is the error I'm getting: Incorrect syntax near 'sprocCUSTOM'.But the error is highlighted at the line that reads "da.Fill(ds);"There's nothing wrong with the stored procedure either.  It exists and works fine. 

View 2 Replies View Related

SqlDataAdapter.Update

Feb 6, 2004

I am using SqlDataAdapter.Update(DataSet) to insert records into multiple tables in one call, but for some reason only first table was inserted.


Dim _cnn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim _sql As String = "Select a,b FROM Table1;Select d, c From Table2;"
Dim _da As New SqlDataAdapter(_sql, _cnn)
Dim _sqlCmdBdr As New SqlCommandBuilder(_da)
Dim _ds As New DataSet
_da.Fill(_ds)
Dim _newrow1 As DataRow = _ds.Tables(0).NewRow
_newrow1("a") = "NewA"
_newrow1("b") = "NewB"
_ds.Tables(0).Rows.Add(_newrow1)

Dim _newrow2 As DataRow = _ds.Tables(1).NewRow
_newrow2("d") = "NewD"
_newrow2("c") = "NewC"
_ds.Tables(1).Rows.Add(_newrow2)

_da.Update(_ds)


new record inserted only into Table1, no new rows in Table2

Please advise!
Thanks

View 1 Replies View Related

SQLDataAdapter Error

Jul 6, 2007

Hi,



I am porting an ASP.NET/C# application from Microsoft Access to SQL Server 2005. In my code I have a method that uses the DataAdapter class to open a table, read some values out of it which are stored, open a second table, read some additional data from it storing the data in the same structure as used before, then updating the first table with the combined data.



When I execute the dataAdapter.Update() method I get the following error:



"Dynamic SQL generation for the Update Command is not supported against a Select Command that does not return any key column information."



I am uncertain what this error is about. This code worked fine against Microsoft Access so it must be something different in how SQL Server works.



Can anyone tell me what this error is complaining about?



Many thanks!



Bob

View 1 Replies View Related

Using Stored Procedures With A SQLDataAdapter

Mar 16, 2007

With MUCH help from this site and its users, I now know how to link a SqlCommand to a stored procedure:
 What I don't know how to do, if it is possible, is to use a stored procedure with a SQLDataAdapter...
Here is the code as I am using, anyone have an idea on how to do this the right way?
' Define data objects
Dim conn As SqlConnection
Dim dataSet As New DataSet
Dim adapter As SqlDataAdapter
If ViewState("FooterDataSet") Is Nothing Then

' Read the connection string from Web.config
Dim connectionString As String = _
ConfigurationManager.ConnectionStrings( _
"Greensheet").ConnectionString
' Initialize connection
conn = New SqlConnection(connectionString)
' Create adapter
adapter = New SqlDataAdapter("SELECT * " & _





"FROM Table " & _





"WHERE (ID= " & intID & ")", conn)
' Fill the DataSet
adapter.Fill(dataSet, "Footer")
' Store the DataSet in view state
ViewState("FooterDataSet") = dataSet
Else

dataSet = ViewState("FooterDataSet")
End If
' Prepare the sort expression using the gridSortDirection and
' gridSortExpression properties
Dim sortExpression As String
If gridSortDirection = SortDirection.Ascending Then

sortExpression = gridSortExpression & " ASC"
Else

sortExpression = gridSortExpression & " DESC"
End If
' Sort the data
dataSet.Tables("Footer").DefaultView.Sort = sortExpression
' Bind the grid to the DataSet
footerGrid.DataSource = _
dataSet.Tables("Footer").DefaultView
footerGrid.DataBind()

View 1 Replies View Related







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