SqlDataReader Object Not Wanting To Close

May 4, 2007

Hi I have double checked my code and cannot pin down why I am getting the error "There is already an open DataReader associated with this Command which must be closed first. "

on the lne:

Line 95:                        DR_IndJobPostings = oComm_IndPostings.ExecuteReader();

I have closed the DR_IndJobPostings object after every use of it as see n on line number 175

 

----------- Code--------------1 /// <summary>
2 /// Will generate and email job alerts based on the frequency
3 /// </summary>
4 /// <param name="frequency">WEEKLY or MONTHLY</param>
5 /// <param name="oServerIN">Instance of Server from ASPX page</param>
6 public void hk_DoAlertByFreq(string frequency, HttpServerUtility oServerIN)
7 {
8 SqlConnection oConn = new SqlConnection(ConfigurationSettings.AppSettings["CString"]);
9 oConn.Open();
10
11 SqlCommand oComm;
12
13 emailSystems oEmail = new emailSystems();
14 HttpServerUtility oServer = oServerIN;
15
16 bool validCall = false;
17 bool industryHasPostings = false;
18 string sEmail = "";
19 string sEmailTemplate = "";
20 string sVacListForEmail = "";
21
22 int IJPost_VacId = 0;
23 int IJPost_EmpId = 0;
24 string IJPost_Req = "";
25 string IJPost_KeyRes = "";
26 string IJPost_VacTitle = "";
27 string IJPost_VacJobTitle = "";
28 string IJPost_VacUrl = "";
29
30 int loopCounter1 = 0;
31
32 string CandEmailAddress = "";
33
34 oComm = new SqlCommand();
35 oComm.Connection = oConn;
36 oComm.CommandType = CommandType.Text;
37
38 SqlCommand oComm_IndPostings = new SqlCommand();
39 oComm_IndPostings.Connection = oConn;
40
41 SqlDataReader DR_Industries;
42 SqlDataReader DR_IndJobPostings;
43 SqlDataReader DR_AlertList;
44
45 if (frequency == "WEEKLY" || frequency == "MONTHLY")
46 {
47 validCall = true;
48 }
49
50 if (validCall)
51 {
52 if (frequency == "WEEKLY")
53 {
54 sEmailTemplate = oEmail.readTextFile("/email_templates/weeklyJobAlert.txt");
55 }
56
57 if (frequency == "MONTHLY")
58 {
59 sEmailTemplate = oEmail.readTextFile("/email_templates/monthlyJobAlert.txt");
60 }
61
62 sSql = "" +
63 "SELECT [id],[industry] FROM S_Utils_Industries " +
64 "WHERE [active] = 1";
65 oComm.CommandText = sSql;
66 DR_Industries = oComm.ExecuteReader();
67
68 if (DR_Industries.HasRows)
69 {
70 //
71 // Loop through each active industry
72 //
73 while (DR_Industries.Read())
74 {
75 industryHasPostings = false;
76 iCurrentIndustryId = (int)DR_Industries.GetSqlInt32(0);
77 sCurrentIndustryText = DR_Industries.GetSqlString(1).ToString();
78
79 // Get all active vacancy postings for this
80 // industry
81 sSql = "SELECT [id]," +
82 "[emp_id], " +
83 "[vac_Requirements]," +
84 "[vac_KeyResp]," +
85 "[vac_VacTitle]," +
86 "[vac_VacJobTitle]," +
87 "FROM [S_Vacancies] " +
88 "WHERE [vac_VacIndustry_Id] = " + iCurrentIndustryId.ToString() + " AND " +
89 "[status] = 1 AND " +
90 "[vac_ListingStart] >= '" + gf.SqlDateTimeFormat(DateTime.Today,1) + "' AND " +
91 "[vac_ListingEnd] < '" + gf.SqlDateTimeFormat(DateTime.Today, 1) + "'";
92
93 oComm_IndPostings.CommandText = sSql;
94
95 DR_IndJobPostings = oComm_IndPostings.ExecuteReader();
96
97 //
98 // If there are job vacancy postings for the industries
99 //
100 if (DR_IndJobPostings.HasRows)
101 {
102 industryHasPostings = true;
103 sEmail = sEmailTemplate;
104
105 //
106 // Loop through the job postings for this industry
107 //
108 while (DR_IndJobPostings.Read())
109 {
110 IJPost_VacId = (int)DR_IndJobPostings.GetSqlInt32(0);
111 IJPost_EmpId = (int)DR_IndJobPostings.GetSqlInt32(1);
112 IJPost_Req = DR_IndJobPostings.GetSqlString(2).ToString();
113 IJPost_KeyRes = DR_IndJobPostings.GetSqlString(3).ToString();
114 IJPost_VacTitle = DR_IndJobPostings.GetSqlString(4).ToString();
115 IJPost_VacJobTitle = DR_IndJobPostings.GetSqlString(5).ToString();
116 IJPost_VacUrl = "http://www.mann-power.net/vJDetails_FromFront.aspx?vid=" + IJPost_VacId.ToString() + "&from=myjobs";
117
118 sVacListForEmail += IJPost_VacTitle + @"
119
120 Job title: " + IJPost_VacJobTitle + @"
121
122 Key Responsibilities
123 " + IJPost_KeyRes + @"
124
125 Requirements
126 " + IJPost_Req + @"
127
128 " + IJPost_VacUrl + @"
129
130 ============================================================
131
132 ";
133 }
134
135
136 sEmail = sEmail.Replace("{VACANCYLIST}", sVacListForEmail);
137
138 // If there are job postings for this industry
139 // get all the people who signed up for a job alert
140 if (industryHasPostings)
141 {
142 sSql = "SELECT [S_JobAlerts].[IndustryId]," +
143 "[S_JobAlerts].[candidateEmail] " +
144 "[S_Cv_Status].[Cv_Online], " +
145 "[S_Cv_Status].[usingShortResume], " +
146 "[S_Cv_Status].[iHasHadIntro] " +
147 "FROM [S_JobAlerts] " +
148 "INNER JOIN [S_Cv_Status] ON " +
149 "[S_Cv_Status].[user_id] = [S_JobAlerts].[candidateUserId] " +
150 "WHERE ([S_JobAlerts].[frequency] = '" + frequency + "') AND " +
151 "[S_JobAlerts].[IndustryId] = " + iCurrentIndustryId.ToString() + "";
152
153 oComm.CommandText = sSql;
154
155 DR_AlertList = oComm.ExecuteReader();
156
157 // If there are candidates who signed up
158 // for a job alert
159 if (DR_AlertList.HasRows)
160 {
161 //
162 // Loop through each job alert for this industry
163 //
164 while (DR_AlertList.Read())
165 {
166 CandEmailAddress = DR_AlertList.GetSqlString(1).ToString();
167 oEmail.sendSingleMail("john.cogan@staffmann.co.za", "Mann-power Job alert", sEmail);
168 }
169
170 }
171 DR_AlertList.Close();
172
173 }
174 }
175 DR_IndJobPostings.Close();
176
177 }
178
179 }
180 DR_Industries.Close();
181
182
183 oConn.Close();
184 } // END: if (validCall)
185
186 }
 

View 1 Replies


ADVERTISEMENT

How To Reorder A SqlDataReader Object

Oct 5, 2007

I have a SqlDataReader object that has some records:
1 hello12 hello23 hello3
Is there a fast/easy way to reorder them?
3 hello32 hello21 hello1
 
 

View 2 Replies View Related

Sqlreader.close() And Sqlconn.close()

Feb 13, 2008

Hi,
My question is if I close the sqlreader i am using. will that close the connection it uses or the connection will still remain open?
Syed

View 4 Replies View Related

Wanting To Use Impersonation

May 2, 2007

Hi,

I like to use impersonation using multiple databases and a user with no login.



I'm working with Powerbuilder 10. I can change users using the command Execute Immediate "EXECUTE AS USER = 'username'". Unfortunately, I can't execute the command 'REVERT' from Powerbuilders Execute Immediate command. The Execute Immediate command prefixes the 'REVERT' command with a exec. ie. exec REVERT.



I thought I could encapsulate the REVERT command in a procedure and run the procedure using Execute Immediate. But, I'm new to SQL Server and I'm not sure if I can.



Does anyone know how to solve this problem? Thanks.



TF

View 3 Replies View Related

Newbie Wanting To Learn

Sep 11, 2004

Hi All,
I am totally new to databases. I am starting from the absolute beginning. I want to learn MS-SQL and was wondering how/where to start. I need info on everything from installation and set-up on an Windows XP PC to programming in SQL. Is there a book or website that can guide me. I am fairly decent at programming and am able understand technical books. Installation and set up are my main concerns right now, since I believe that once I have a stable system to learn on, SQL should be easy.
Thanks!

View 6 Replies View Related

Linked Server Not Wanting To Connect

Sep 11, 2007

Morning ALL.

I have a utility server that I am running SS2K5 SP2 w/ the latest patches.

It has numerous Linked Server to both SS2K and SS2K5 servera already in place and working great.

I scripted out (numerous times) a Link Server create statement for a SS2K5 server that is working great and then changed the server name in the script to reflect the new server name and executed it.

It DID created the linked server BUT when it finished up it generated the following message:


================ ERROR TEXT BEGIN ======================

TITLE: Microsoft SQL Server Management Studio
------------------------------
"The test connection to the linked server failed."
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "DC:AUS02DB21".
OLE DB provider "MSDASQL" for linked server "DC:AUS02DB21" returned message "[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (PreLoginHandshake()).".
OLE DB provider "MSDASQL" for linked server "DC:AUS02DB21" returned message "[Microsoft][ODBC SQL Server Driver][DBNETLIB]General network error. Check your network documentation.". (Microsoft SQL Server, Error: 7303)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=7303&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------

============= ERROR TEXT END ==============


Now when I try to open the Catalogs object under the newly created Linked Server, I get the following message each time I try to open it:


================ ERROR TEXT BEGIN ======================

TITLE: Microsoft SQL Server Management Studio
------------------------------
Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "DC:AUS02DB21". (Microsoft SQL Server, Error: 7303)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=7303&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------

============= ERROR TEXT END ==============


Here is the code that I used as a template (and which is from a SS2K5 server that is working fine)

=========== CODE BEGIN ========


/****** Object: LinkedServer [DC:AUS02DB19] Script Date: 09/11/2007 10:30:42 ******/

EXEC master.dbo.sp_addlinkedserver @server = N'DC:AUS02DB19', @srvproduct=N'OLE DB for ODBC', @provider=N'MSDASQL', @provstr=N'DRIVER={SQL Server};SERVER=AUS02DB19.DomainName.com;UID=user;PWD=password;'

/* For security reasons the linked server remote logins password is changed with ######## */

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'DC:AUS02DB19',@useself=N'False',@locallogin=NULL,@rmtuser=N'SQL_',@rmtpassword='########'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'collation compatible', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'data access', @optvalue=N'true'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'dist', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'pub', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'rpc', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'rpc out', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'sub', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'connect timeout', @optvalue=N'0'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'collation name', @optvalue=null

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'lazy schema validation', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'query timeout', @optvalue=N'0'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB19', @optname=N'use remote collation', @optvalue=N'true'

=========== CODE END ==========

Here is what the code looks like when I replaced the name of DB19 to DB21 globally throughout the script:

=========== CODE BEGIN ========


/****** Object: LinkedServer [DC:AUS02DB21] Script Date: 09/11/2007 10:30:42 ******/

EXEC master.dbo.sp_addlinkedserver @server = N'DC:AUS02DB21', @srvproduct=N'OLE DB for ODBC', @provider=N'MSDASQL', @provstr=N'DRIVER={SQL Server};SERVER=AUS02DB21.DomainName.com;UID=user;PWD=password;'

/* For security reasons the linked server remote logins password is changed with ######## */

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'DC:AUS02DB21',@useself=N'False',@locallogin=NULL,@rmtuser=N'SQL_',@rmtpassword='########'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'collation compatible', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'data access', @optvalue=N'true'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'dist', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'pub', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'rpc', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'rpc out', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'sub', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'connect timeout', @optvalue=N'0'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'collation name', @optvalue=null

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'lazy schema validation', @optvalue=N'false'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'query timeout', @optvalue=N'0'

GO

EXEC master.dbo.sp_serveroption @server=N'DC:AUS02DB21', @optname=N'use remote collation', @optvalue=N'true'

=========== CODE END ==========

Now I have masked the real values in this post of the @provstr string for obvious reasons and the real Linked Server object has all the correct parameters set.


@provstr=N'DRIVER={SQL Server};SERVER=AUS02DB21.DomainName.com;UID=user;PWD=pass;'

SO ... what am I missing?

Thanks ALL

View 5 Replies View Related

SSIS Issue With Flat Files Not Wanting To See CR/LF

Mar 14, 2008

I have an issue with an SSIS package I was hoping to get some commentary on.

I am taking a flat file, scrubbing it in SSIS, and exporting it into a different package.

The files are fixed width. Both Fixed Width, and Ragged Right settings are not working, I've tried both.

My current config on the flat file connection is set to use the file name as variable. The format is "Ragged Right". The Text Qualifier is "<none>". The Header row and Header rows to skip are <CR><LF> and 0. The column names in first row are not checked.

In the advanced tab, 43 columns are defined. The output and input have all been verified numerous times to conform to the file spec.

When previewing the file in preview, only one record shows up even though the file contains multiple.

What it's doing is the last column contains the CR and LF characters and then it continues putting the other rows in that column (it is ignoring the CR LF and not going to the next row)

WHen I click on "Columns" in the flat file connector, it displays the rows of information as it should. When I click back down to preview a second time, the rows are displayed as they should.

The initial time you preview, the rows are jacked up and all smashed onto the first row. WHen trying to execute the package, I get a truncation error because the last column is supposed to be 7 in length, and contains multiple data rows in it.

When trying the option "Fixed Width" it does the same thing. It ignores the CR LF and makes everything one row.

Can someone please explain what it is I'm doing wrong? Or why when I click to preview the first time it is broken, but when clicking on columns and then back to Preview it is fixed?

View 6 Replies View Related

Wanting To Condense A Bunch Of SELECT Statements

Aug 27, 2007

Hi All,

Not sure if this is exactly the place to post this, but here it goes anyways.

I am writing a ASP.Net/C# program and I am interacting with a MS Access database in order to derive data on user login and logout times. Basically, I am trying to create a line graph that will display the number of users over the course of a user specified timespan. Currently, I am doing this by look at the number of users that were logged on during each minute of the timespan.

My database table setup consists of a EmployeeID column (Text), Logon Date (Date/Time), and Logoff Date (Date/Time). I have also created an index on the Logon Date and Logoff Date columns.

In order to view the number of users during a minute of the timespan I use a Jet SQL query of the following format




Code Snippet
SELECT DISTINCT Count (EmployeeID) AS [User Count]
FROM ProgramName
WHERE ([Logon Date] < #August 27, 2007 11:45:00# OR [Logon Date] Is Null) AND ([Logoff Date] > #August 27, 2007 11:45:00# OR [Logoff Date] Is Null)




The problem is that using this method I have to execute 1,440 queries for each day in the timespan. Currently this takes about 25 seconds to execute if the timespan is a full workweek (7,200 queries).

Now the question. Is it possible to create a SELECT statement that will return user counts for multiple minutes? Like maybe a SELECT statement that returns a column of counts for every minute in an hour? If it is possible, does anyone have any examples? I am hoping by lowering the number of queries my program has to execute I will also cut down the time required for the code to run.

I am pretty new to SQL, so any guidance or advice is very appreciated.

Thanks!

View 4 Replies View Related

Results From Query Are TRUE And FALSE But Users Wanting YES And NO

Jan 7, 2004

Hi everyone.

I've got a Select query that pulls out some data from my database. Two of the columns are both booleans (bit's of size 1) so they come back as TRUE and FALSE - which I thought was fine.

However, the users are wanting to see YES and NO since they find TRUE and FALSE confusing (yes I know how silly that sounds).

Is there any way I can do this?

My query is like this:
SELECT [stuff], [things] FROM [table1], [table2] WHERE [table1].[condition] = [table2].[condition]

Thanks
Andrew

View 4 Replies View Related

Wanting To Move An Entire Database Using Backup? Export? That Takes All Users, All Data, All Permissions

Apr 25, 2008

I've had issues where backup up and restoring data from sqlserver2005 does not reattach the data to the correct users.  Any tips on how to best accomplish full database moves where data is owned by different security users?
thanks,

View 2 Replies View Related

Close

Apr 6, 2006

View 3 Replies View Related

Object Reference Not Set To An Instance Of An Object When Retrieving Data/Schema In Design Time

Oct 11, 2006

Hi There,This is related to a ms access database but since I use the SqlDataSource control I thought I should post here.I have a project that I was working on with this ms access db and using sql controls, everything was working just finesince one day I started getting "Object reference not set to an instance of an object" messages when I try to designa query or retrieve a schema,  nothing works at design time anymore but at runtime everything is perfect, its a lotof work for me now to create columns,schemas and everything manually, I've tried reinstalling visualstudio, ado componentsbut nothing seems to fix it, did this ever happen to any of you guys?any tip is really appreciated  thanks a lot 

View 2 Replies View Related

Server Error: Object Reference Not Set To An Instance Of An Object. Trying To Upload Image In Database

Dec 17, 2007

Does any one has any clue for this error ? I did went through a lot of articles on this error but none helped . I am working in Visual studie 2005 and trying to upload image in sql database through a simple form. Here is the code
 
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.SqlClient;
using System.Web.Configuration;
using System.IO;
public partial class Binary_frmUpload : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e)
{
}protected void btnUpload_Click(object sender, EventArgs e)
{if (FileUpload.HasFile == false)
{
// No file uploaded!lblUploadDetails.Text = "Please first select a file to upload...";
}
else
{string str1 = FileUpload.PostedFile.FileName;
 string str2 = FileUpload.PostedFile.ContentType; string connectionString = WebConfigurationManager.ConnectionStrings["GSGA"].ConnectionString;
//Initialize SQL Server Connection SqlConnection con = new SqlConnection(connectionString);
//Set insert query string qry = "insert into Officers (Picture,PictureType ,PicttureTitle) values(@ImageData, @PictureType, @PictureTitle)";
//Initialize SqlCommand object for insert. SqlCommand cmd = new SqlCommand(qry, con);
//We are passing Original Image Path and Image byte data as sql parameters. cmd.Parameters.Add(new SqlParameter("@PictureTitle", str1));
cmd.Parameters.Add(new SqlParameter("@PictureType", str2));Stream imgStream = FileUpload.PostedFile.InputStream;
int imgLen = FileUpload.PostedFile.ContentLength;byte[] ImageBytes = new byte[imgLen]; cmd.Parameters.Add(new SqlParameter("@ImageData", ImageBytes));
//Open connection and execute insert query.
con.Open();
cmd.ExecuteNonQuery();
con.Close(); //Close form and return to list or images.
 
}
}
}
 
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.Source Error:



Line 32:
Line 33: string str2 = FileUpload.PostedFile.ContentType;
Line 34: string connectionString = WebConfigurationManager.ConnectionStrings["GSGA"].ConnectionString;
Line 35:
Line 36: //Initialize SQL Server Connection Source File: c:UsersManojDocumentsVisual Studio 2005WebSitesGSGABinaryfrmUpload.aspx.cs    Line: 34  
Stack Trace:




[NullReferenceException: Object reference not set to an instance of an object.]
Binary_frmUpload.btnUpload_Click(Object sender, EventArgs e) in c:UsersManojDocumentsVisual Studio 2005WebSitesGSGABinaryfrmUpload.aspx.cs:34
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

View 2 Replies View Related

' The Definition Of Object [object Name] Has Changed Since It Was Compiled' Error When Altering A Trigger In 2005

Aug 17, 2007

Hello All

Not sure if this is the right forum to post this question to, so if it's not, please accept my apologies.

I'm working in SQL Server 2005 with a database that was migrated to 2005 from SQL Server 2000. I have to alter a trigger on a table for some functionality changes, and when I modify the trigger and then access it through the application the database is working with, I receive this error:


There was a error in the [stored procedure name] procedure. Error Number: -2147217900 Error Description: [Microsoft][ODBC SQL Server Driver][SQL Server]The definition of object '[trigger name]' has changed since it was compiled.


[stored procedure name] and [trigger name] are where the actual names appear in the message.

I've tried running sp_recompile on the trigger, stored procedure, and table that are associated with this, and nothing works. I have dropped the trigger, which allows the save process to complete (but doesn't perform the required functionality, of course), and then re-created the trigger, but the error message still comes up. The compatibility level for the database is SQL Server 2000 (80) (as it was migrated from SQL Server 2000 as I mentioned above).

Has anyone seen this, and if so, how can I fix it?

Thanks in advance for your help!

Jay

View 4 Replies View Related

When Using A Sqldataadapter In VS 2005 I Get The Following Error At Runtime. Object Reference Not Set To An Instance Of An Object

Dec 21, 2006

Help! I have posted this before and I had hoped that the VS2005 SP1 would help my problem. It didn't. My code is shown below. I have dropped a sqlconnection, sqldataadapter and a strongly-typed dataset from the toolbox onto the component designer for my page and written my code. It compiles without any errors but at runtine I receive the system error "Object reference not set to an instance of an object." The error occurs at the first line where the sqldataadapter is mentioned. I have shufflled the code and the error still occurs at first mention of the dataadapter. I have set parameters to a simple string such as "myemail." It hasn't helped. I have used the "Dim" statement as "Dim DaAuthorLogin as System.Data.SqlClient.SqlDataadapter and Dim DaAuthorLogin as New ......) at the start of the private sub generated by the event requiring the data. Nothing helps. Here is my simple code to select data from a sqlserver 2000 database. Why do I continue to get this error?
Partial Class AuthorLogin
Inherits System.Web.UI.Page
Protected WithEvents AuthorInformation As System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.DaAuthorLogin = New System.Data.SqlClient.SqlDataAdapter
Me.MDData = New System.Data.SqlClient.SqlConnection
Me.DsAuthorLogin = New MedicalDecisions.DsAuthorLogin
CType(Me.DsAuthorLogin, System.ComponentModel.ISupportInitialize).BeginInit()
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT AuthorAlias, AuthorEmail, AuthorPassword, LastName, PreferredName" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "FRO" & _
"M T_Author" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "WHERE (AuthorEmail = @AuthorEmail) AND (AuthorPassword =" & _
" @AuthorPassword)"
Me.SqlSelectCommand1.Connection = Me.MDData
Me.SqlSelectCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@AuthorEmail", System.Data.SqlDbType.NVarChar, 50, "AuthorEmail"), New System.Data.SqlClient.SqlParameter("@AuthorPassword", System.Data.SqlDbType.NVarChar, 50, "AuthorPassword")})
'
'DaAuthorLogin
'
Me.DaAuthorLogin.SelectCommand = Me.SqlSelectCommand1
Me.DaAuthorLogin.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "T_Author", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("AuthorAlias", "AuthorAlias"), New System.Data.Common.DataColumnMapping("AuthorEmail", "AuthorEmail"), New System.Data.Common.DataColumnMapping("AuthorPassword", "AuthorPassword"), New System.Data.Common.DataColumnMapping("LastName", "LastName"), New System.Data.Common.DataColumnMapping("PreferredName", "PreferredName")})})
'
'MDData
'
Me.MDData.ConnectionString = "Data Source=CIS1022DAVID;Initial Catalog=CGData;Integrated Security=True;Pooling" & _
"=False"
Me.MDData.FireInfoMessageEventOnUserErrors = False
'
'DsAuthorLogin
'
Me.DsAuthorLogin.DataSetName = "DsAuthorLogin"
Me.DsAuthorLogin.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
CType(Me.DsAuthorLogin, System.ComponentModel.ISupportInitialize).EndInit()
End Sub
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents MDData As System.Data.SqlClient.SqlConnection
Friend WithEvents DaAuthorLogin As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents DsAuthorLogin As MedicalDecisions.DsAuthorLogin
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs)
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
'no code here
End Sub
Private Sub AuthorLoginRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AuthorLoginRegister.Click
'for new author registration
Response.Redirect("AuthorInformation.aspx")
End Sub
Private Sub AuthorLoginBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AuthorLoginBack.Click
'to navigate back
Response.Redirect("MainPaths.aspx")
End Sub
Protected Sub AuthorLoginPassword_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AuthorLoginPassword.TextChanged
'pass the parameters to the dataadapter and return dataset
DaAuthorLogin.SelectCommand.Parameters("@AuthorEmail").Value = AuthorLoginEmail.Text
DaAuthorLogin.SelectCommand.Parameters("@AuthorPassword").Value = AuthorLoginPassword.Text
MDData.Open()
DaAuthorLogin.Fill(DsAuthorLogin, "T_Author")
MDData.Close()
'set session objects
If DsAuthorLogin.T_Author.Rows.Count > 0 Then
Session("AuthorAlias") = DsAuthorLogin.T_Author(0).AuthorAlias
Session("LastName") = DsAuthorLogin.T_Author(0).LastName
Session("PreferredName") = DsAuthorLogin.T_Author(0).PreferredName
Response.Redirect("AuthorPaths.aspx")
Else : AuthorLoginNotValid.Visible = True
AuthorLoginEmail.Text = ""
AuthorLoginPassword.Text = ""
End If
End Sub
End Class
 
Thanks in advance,
David

View 2 Replies View Related

Error: The Script Threw An Exception: Object Reference Not Set To An Instance Of An Object.

Sep 12, 2006



Anyone know what this error means and how to get rid of it?



Public Sub Main()

Dim myMessage As Net.Mail.MailMessage

Dim mySmtpClient As Net.Mail.SmtpClient

myMessage.To(20) = New Net.Mail.MailAddress(me@hotmail.com)

myMessage.From = New Net.Mail.MailAddress(someone@microsoft.com)

myMessage.Subject = "as;dlfjsdf"

myMessage.Priority = Net.Mail.MailPriority.High

mySmtpClient = New Net.Mail.SmtpClient("microsoft.com")

mySmtpClient.Send(myMessage)

Dts.TaskResult = Dts.Results.Success

End Sub



Thanks,

View 4 Replies View Related

Predict Query Gives 'DMPluginWrapper; Object Reference Not Set To An Instance Of An Object' Error

Mar 17, 2008



Hi,

I am trying to develop a custom algorithm. I have implemented and tested training methods, however I fail at prediction phase. When I try to run a prediction query against a model created with my algorithm I get:


Executing the query ...
Obtained object of type: Microsoft.AnalysisServices.AdomdClient.AdomdDataReader
COM error: COM error: DMPluginWrapper; Object reference not set to an instance of an object..
Execution complete


I know this is not very descriptive, but I have seen that algorith doesn't even executes my Predict(..) function (I can test this by logging to a text file)
So the problem is this, when I run prediction query DMPluginWrapper gives exception -I think- even before calling my custom method.

As I said it is not a very descriptive message but I hope I have hit a general issue.

Thanks...

View 3 Replies View Related

Delete SQL Script As400 Throwing Object Reference Not Set To An Instance Of An Object

Apr 2, 2008

I am trying to send some data back to our as/400 from SQL server. Before I do so I need to delete entries from the table. I have an odbc connection set up and have used it sucessfully in a datareader compoenent but but when I try to use it for a delete SQL task it give me the followign error. what am I doing wrong? I even tried hardcoding in the system name/library name.

Here is my delete sql script
DELETE FROM DSSCNTL Where Companycode = 10


TITLE: SQL Task
------------------------------
Object reference not set to an instance of an object.
------------------------------
BUTTONS:
OK
------------------------------

View 7 Replies View Related

Object Reference Not Set To An Instance Of An Object. MSSQL Server Report Builder

Feb 15, 2007

When I try and run Report Builder Reports i get this error message "Object reference not set to an instance of an object. "

I can run reports locally but not from Report manager

here is the stack trace info

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:





An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:





[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.Reporting.WebForms.WebRequestHelper.GetExceptionForMoreInformationNode(XmlNode moreInfo, XmlNamespaceManager namespaces) +18
Microsoft.Reporting.WebForms.WebRequestHelper.ExceptionFromWebResponse(Exception e) +358
Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream outputStream, String& mimeType, String& fileNameExtension) +482
Microsoft.Reporting.WebForms.ServerReport.InternalRender(Boolean isAbortable, String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +958
Microsoft.Reporting.WebForms.ServerReportControlSource.RenderReport(String format, String deviceInfo, NameValueCollection additionalParams, String& mimeType, String& fileExtension) +84
Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +143
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +75
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64





Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

View 3 Replies View Related

Power Pivot :: Cannot Save File Object Reference Not Set To Instance Of Object

May 13, 2015

Getting the following error-message:

OS: Windows Server 2008 R2 Standard
64bit
Office 2010

Power Pivot Tables are fed by Power Query queries.

View 3 Replies View Related

Close The Connection?

Jul 17, 2006

Hi, I've created a simple hit counter in my Session_Start event...
Dim myDataSource As New SqlDataSourcemyDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString1").ToStringmyDataSource.UpdateCommand = "UPDATE Stats SET Hits = Hits + 1"myDataSource.Update()
It works fine but do I need to close the connection after I've finished with it or is this ok?
Thanks for your help.
 

View 9 Replies View Related

@@identity... Am I Even Close Here?

May 29, 2007

string ConnectionString = ConfigurationManager.ConnectionStrings["myConnString"].ConnectionString;
SqlConnection connection = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand(@"INSERT INTO CreditAppFile (GI_RB_Div) VALUES(@GI_RB_Div) SELECT @@idientity as 'NewID'", connection);
cmd.Parameters.Add("@ID", SqlDbType.BigInt, 8).Value = NewID.Text;
.
.
Response.Redirect(DisplayPage.aspx?ID=@ID);
 
i want the ID of the most recently added record to be passed to another page to show all entered data from the prior page...  am i close?

View 5 Replies View Related

Am I Close Or Way Off The Mark?

Jul 20, 2007

I am trying to select rows from a SQL2000 database table and then write a random number back into each row. I have already looked into do it all in a SP but there are well documented limitations for the SQL RAND function when called in the same batch, so I need to somehow do in .Net what I already have working in classic ASP.
I can't get the  UPDATE (part two section) to compile. I don't know how to call the stored procedure inside the 'foreach' loop or extract the SP parameters.  I have it working in classic asp but am having a lot of trouble converting to .Net 2.0.  Is the below even close to working? 
// stored procedure to write externally generated random number value into database
PROCEDURE RandomizeLinks@L_ID int,@L_Rank intASUPDATE Links SET L_Rank = @L_RankWHERE (L_ID = @L_ID)
// Part One select links that need random number inserted.
    public DataTable GetRandLinks()    {        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1A"].ConnectionString);        SqlCommand cmd = new SqlCommand("RandomizerSelect001", con);        cmd.CommandType = CommandType.StoredProcedure;        SqlDataAdapter da = new SqlDataAdapter();        da.SelectCommand = cmd;        DataSet ds = new DataSet();        try        {            da.Fill(ds, "Random001");            return ds.Tables["Random001"];        }        catch        { throw new ApplicationException("Data error"); }    }
    // Part Two I need two write a random number back into each row
    protected void Button1_Click(object sender, EventArgs e)    {        GetRandLinks();        int LinkID;               // this generates unassigned local variable "LinkID' error        int LRank;              // this generates unassigned local variable "LRank' error        SqlConnection con2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1A"].ConnectionString);        SqlCommand cmd2 = new SqlCommand("RandomizeLinks", con2);        cmd2.CommandType = CommandType.StoredProcedure;        cmd2.Parameters.AddWithValue("@L_ID", LinkID);        cmd2.Parameters.AddWithValue("@L_Rank", LRank);        SqlDataAdapter da2 = new SqlDataAdapter();
        int RowIncrement;        RowIncrement = 0;        DataTable dt = GetRandLinks();        foreach (DataRow row in dt.Rows)        {            System.Random myRandom = new System.Random();            int LinkRank = myRandom.Next(25, 250);            LRank = LinkRank;            da2.UpdateCommand = cmd2;            RowIncrement++;        }           }

View 4 Replies View Related

Do I Need To Close The Connection????

Feb 14, 2008

Hi all,
 
If this is used eg.
Return selectCommand.ExecuteReader(CommandBehaviour.Default)
Here  do i need to close the connection in finally explicitly????
Are there any links which can answer this kind of question ???
Thanks for any help in advance.....

View 3 Replies View Related

ADO.net (how To Close A Reader)

Nov 29, 2005

Hello, I'm trying to run the following snippet as Console app, and I get an error: "a reader is already open for this connection, and should be closed first" I tried to manually say: SqlDataReader.Close() in the begining of the code, but still get the error, Any suggecstions how to manually close the reader? thank you ---------- here's the code -----------using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; namespace ADO.NET { /// <summary> /// Summary description for Class1. /// </summary> class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { SqlConnection cn = new SqlConnection ("SERVER=MyServer; INTEGRATED SECURITY=TRUE;" + "DATABASE=AdventureWorks"); SqlCommand cmd1 = new SqlCommand ("Select * from HumanResources.Department", cn); cmd1.CommandType = CommandType.Text; try { cn.Open(); SqlDataReader rdr = cmd1.ExecuteReader(); while (rdr.Read()) { if (rdr["Name"].ToString() == "Production") { SqlCommand cmd2 = new SqlCommand("SELECT * FROM " + "HumanResources.Employee WHERE DepartmentID = 7", cn); cmd2.CommandType = CommandType.Text; SqlDataReader rdr2 = cmd2.ExecuteReader(); while (rdr2.Read()) { } rdr2.Close(); } } rdr.Close(); } catch (Exception ex) { Console.WriteLine (ex.Message); } finally { cn.Close(); } } } }

View 2 Replies View Related

How Can I Close A Cursor?

Jul 12, 2002

Hi guys.

is there anyway I can find a cursor that is open
so that i can close it?

I have a procedure running daily (across servers). that stopped suddenly with this error.

A cursor with the name 'xyz' already exists.

I tried closing and deallocating on destination server. I am getting the error like "cursor doesnot exist"

I need to run this procedure. i dont want to recycle the destination server.

any ideas?
-MAK

View 4 Replies View Related

T-SQL CLOSE Connection To DB

May 28, 2006

How do i close a current connection to a database using t-sql?I fail some time to drop the database getting messages that it'scurrently in use.Using the wizard to delete the database, i could check the option toclose all connections to the db, but how do i do it using t-sql?best regards

View 10 Replies View Related

How To Close CN Connection To A SDF Db

Oct 14, 2007



Hello all,

I have a DB on my WM2005 device.
I'm using a program which connect to the DB using a CN.
On the constructor of the DB Class I use the line


static string connString = "Data Source='" + strDB + "'; LCID=1033; Password=" + strPass + "; Encrypt = FALSE;";
SqlCeConnection cn = new SqlCeConnection(connString);


Then I Open the Connection.
Now, in some ways I need to drop a Table.
Before I do so, I disconnect the DB but I'm using only the line

cn.Close();


I saw om the Watch attributes that its not a real disconnect to the DB.
When I try to Drop the Table I get this message:
The system timed out waiting for a lock. [ Session id = 25,Thread id = -2096711882,Process id = -2090594918,Table name = Movies,Conflict type = x lock (s blocks),Resource = DDL ]


And the Table doesn't drop.

Is it related to the constructor line I made?
What is the best solution to Drop a table..and then to get connected again with the DB.

Thanks in advance..

View 5 Replies View Related

Microsoft Visual Studio Is Unable To Load This Document: Object Reference Is Not Set To An Instance Of An Object

Apr 8, 2008

Hi Everyone,
Please help me on this issue. I'm a new SSIS User.
I've installed Sql Server 2005 Developer Edition
When I create a new SSIS Project in Business Intelligence Development Studio,
I get the following message:
"Microsoft Visual Studio is unable to load this document: Object reference is not set to an instance of an object".
Error loading 'package.dtsx'bject reference is not set to an instance of an object
When I try to debug the package, I get the below message:
parameter Component(System.Design) is null.
I've uninstalled and installed SS 2005 several times, yet the problem persists.
Please help.
This is the package.dtsx

<?xml version="1.0"?><DTS:Executable xmlnsTS="www.microsoft.com/SqlServer/Dts" DTS:ExecutableType="MSDTS.Package.1"><DTSroperty DTS:Name="PackageFormatVersion">2</DTSroperty><DTSroperty DTS:Name="VersionComments"></DTSroperty><DTSroperty DTS:Name="CreatorName">USkothand1</DTSroperty><DTSroperty DTS:Name="CreatorComputerName">US6051KOTHAND1</DTSroperty><DTSroperty DTS:Name="CreationDate" DTSataType="7">4/8/2008 10:53:39 AM</DTSroperty><DTSroperty DTS:Name="PackageType">5</DTSroperty><DTSroperty DTS:Name="ProtectionLevel">1</DTSroperty><DTSroperty DTS:Name="MaxConcurrentExecutables">-1</DTSroperty><DTSroperty DTS:Name="PackagePriorityClass">0</DTSroperty><DTSroperty DTS:Name="VersionMajor">1</DTSroperty><DTSroperty DTS:Name="VersionMinor">0</DTSroperty><DTSroperty DTS:Name="VersionBuild">0</DTSroperty><DTSroperty DTS:Name="VersionGUID">{FBD98635-EDDE-4F58-9D53-356E8CB653FB}</DTSroperty><DTSroperty DTS:Name="EnableConfig">0</DTSroperty><DTSroperty DTS:Name="CheckpointFileName"></DTSroperty><DTSroperty DTS:Name="SaveCheckpoints">0</DTSroperty><DTSroperty DTS:Name="CheckpointUsage">0</DTSroperty><DTSroperty DTS:Name="SuppressConfigurationWarnings">0</DTSroperty><DTSroperty DTS:Name="ForceExecValue">0</DTSroperty><DTSroperty DTS:Name="ExecValue" DTSataType="3">0</DTSroperty><DTSroperty DTS:Name="ForceExecutionResult">-1</DTSroperty><DTSroperty DTS:Name="Disabled">0</DTSroperty><DTSroperty DTS:Name="FailPackageOnFailure">0</DTSroperty><DTSroperty DTS:Name="FailParentOnFailure">0</DTSroperty><DTSroperty DTS:Name="MaxErrorCount">1</DTSroperty><DTSroperty DTS:Name="ISOLevel">1048576</DTSroperty><DTSroperty DTS:Name="LocaleID">1033</DTSroperty><DTSroperty DTS:Name="TransactionOption">1</DTSroperty><DTSroperty DTS:Name="DelayValidation">0</DTSroperty>

<DTS:LoggingOptions><DTSroperty DTS:Name="LoggingMode">0</DTSroperty><DTSroperty DTS:Name="FilterKind">1</DTSroperty><DTSroperty DTS:Name="EventFilter" DTSataType="8"></DTSroperty></DTS:LoggingOptions><DTSroperty DTS:Name="ObjectName">Package</DTSroperty><DTSroperty DTS:Name="DTSID">{191D188C-EA6E-46D6-A46A-8C9F3C21C321}</DTSroperty><DTSroperty DTS:Name="Description"></DTSroperty><DTSroperty DTS:Name="CreationName">MSDTS.Package.1</DTSroperty><DTSroperty DTS:Name="DisableEventHandlers">0</DTSroperty></DTS:Executable>
Thanks
Best Regards

View 12 Replies View Related

Problem In Converting MS Access OLE Object[Image] Column To BLOB (binary Large Object Bitmap)

May 27, 2008

Hi All,
i have a table in MS Access with CandidateId and Image column. Image column is in OLE object  format. i need to move this to SQL server 2005 with CandidateId column with integer and candidate Image column to Image datatype.
its very udgent, i need any tool to move this to SQL server 2005 or i need a code to move this table from MS Access to SQL server 2005 in C#.
please do the needfull ASAP. waiting for your reply
with regards
 
 
 

View 1 Replies View Related

VS 2005 Error 'Object Reference Not Set To An Instance Of An Object' With Integration Services Project Create Failure

May 22, 2008



Just installed VS 2005 & SQLServer 2005 clients on my workstation. When trying to create a new Integration Services Project and start work in the designer receive the MICROSOFT VISUAL STUDIO 'Object reference not set to an instance of an object.' dialog box with message "Creating project 'Integration Services project1'...project creation failed."

Previously I had SQLServer 2000 client with the little VS tool that came with it installed. Uninstalled these prior to installing the 2005 tools (VS and SQLServer).

I'm not finding any information on corrective action for this error.

Any one have this problem and found the solution?

Thanks,
CLC

View 1 Replies View Related

Object Reference Not Set To An Instance Of An Object (Inserting Data Into Database)

Dec 28, 2004

Each time I press submit to insert data into the database I receive the following message. I use the same code on another page and it works fine. Here is the error:


Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 125: MyCommand.Parameters("@Balance").Value = txtBalance.Text
Line 126:
Line 127: MyCommand.Connection.Open()
Line 128:
Line 129: Try


Source File: c:inetpubwwwrootCreditRepairCreditor_Default.aspx.vb Line: 127

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
CreditRepair.CreditRepair.Vb.Creditor_Default.btnSaveAdd_Click(Object sender, EventArgs e) in c:inetpubwwwrootCreditRepairCreditor_Default.aspx.vb:127
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()



Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

If (Page.IsValid) Then

Dim DS As DataSet
Dim MyCommand As SqlCommand

Dim AddAccount As String = "insert into AccountDetails (Account_ID, Report_ID, Balance) values (@Account_ID, @Report_ID, @Balance)"

MyCommand = New SqlCommand(AddAccount, MyConnection)

MyCommand.Parameters.Add(New SqlParameter("@Account_ID", SqlDbType.Char, 50))
MyCommand.Parameters("@Account_ID").Value = txtAccount_ID.Text

MyCommand.Parameters.Add(New SqlParameter("@Report_ID", SqlDbType.Char, 50))
MyCommand.Parameters("@Report_ID").Value = txtReport_ID.Text

MyCommand.Parameters.Add(New SqlParameter("@Balance", SqlDbType.Char, 50))
MyCommand.Parameters("@Balance").Value = txtBalance.Text

MyCommand.Connection.Open()

MyCommand.ExecuteNonQuery()

Response.Redirect("Customer_Details.aspx?SS='CustHeadGrid.Columns[0].Item.lblSS.Text)")

MyCommand.Connection.Close()
End If

View 2 Replies View Related

Script Task Error --Object Reference Not Set To An Instance Of An Object

Sep 13, 2006

I am trying to execute this code feom Script task while excuting its giving me error that "Object reference not set to an instance of an object." The assemblies Iam referening in this code are there in GAC. Any idea abt this.



Thanks,

Public Sub Main()

Dim remoteUri As String

Dim fireAgain As Boolean

Dim uriVarName As String

Dim fileVarName As String

Dim httpConnection As Microsoft.SqlServer.Dts.Runtime.HttpClientConnection

Dim emptyBytes(0) As Byte

Dim SessionID As String

Dim CusAuth As CustomAuth

Try

' Determine the correct variables to read for URI and filename

uriVarName = "vsReportUri"

fileVarName = "vsReportDownloadFilename"

' create SessionID for use with HD Custom authentication

CusAuth = New CustomAuth(ASCIIEncoding.ASCII.GetBytes(Dts.Variables("in_vsBatchKey").Value.ToString()))



Dts.Variables(uriVarName).Value = Dts.Variables(uriVarName).Value.ToString() + "&" + _

"BeginDate=" + Dts.Variables("in_vsBeginDate").Value.ToString() + "&" + _

"EndDate=" + Dts.Variables("in_vsEndDate").Value.ToString()

Dim request As HttpWebRequest = CType(WebRequest.Create(Dts.Variables(uriVarName).Value.ToString()), HttpWebRequest)

'Set credentials based on the credentials found in the variables

request.Credentials = New NetworkCredential(Dts.Variables("in_vsReportUsername").Value.ToString(), _

Dts.Variables("in_vsReportPassword").Value.ToString(), _

Dts.Variables("in_vsReportDomain").Value.ToString())

'Place the custom authentication session ID in a cookie called BatchSession

request.CookieContainer.Add(New Cookie("BatchSession", CusAuth.GenerateSession("EmailAlertingSSIS"), "/", Dts.Variables("in_vsReportDomain").Value.ToString()))

' Set some reasonable limits on resources used by this request

request.MaximumAutomaticRedirections = 4

request.MaximumResponseHeadersLength = 4

' Prepare to download, write messages indicating download start

Dts.Events.FireInformation(0, String.Empty, String.Format("Downloading '{0}' from '{1}'", _

Dts.Variables(fileVarName).Value.ToString(), Dts.Variables(uriVarName).Value.ToString()), String.Empty, 0, fireAgain)

Dts.Log(String.Format("Downloading '{0}' from '{1}'", Dts.Variables(fileVarName).Value.ToString(), Dts.Variables(uriVarName).Value.ToString()), 0, emptyBytes)

' Download data

Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)

' Get the stream associated with the response.

Dim receiveStream As Stream = response.GetResponseStream()

' Pipes the stream to a higher level stream reader with the required encoding format.

Dim readStream As New StreamReader(receiveStream, Encoding.UTF8)

Dim fileStream As New StreamWriter(Dts.Variables(fileVarName).Value.ToString())

fileStream.Write(readStream.ReadToEnd())

fileStream.Flush()

fileStream.Close()

readStream.Close()

fileStream.Dispose()

readStream.Dispose()



'Download the file and report success

Dts.TaskResult = Dts.Results.Success

Catch ex As Exception

' post the error message we got back.

Dts.Events.FireError(0, String.Empty, ex.Message, String.Empty, 0)

Dts.TaskResult = Dts.Results.Failure

End Try

End Sub

View 1 Replies View Related







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