Click here to Skip to main content
15,897,891 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionProble with sending email in asp.net 1.1 Pin
narithchap23-Jul-09 18:18
narithchap23-Jul-09 18:18 
AnswerRe: Proble with sending email in asp.net 1.1 Pin
Christian Graus23-Jul-09 19:31
protectorChristian Graus23-Jul-09 19:31 
GeneralHelp on people posting comments on my website [Moved] Pin
T. Cody23-Jul-09 14:59
T. Cody23-Jul-09 14:59 
GeneralRe: Help on people posting comments on my website Pin
Richard Andrew x6423-Jul-09 15:06
professionalRichard Andrew x6423-Jul-09 15:06 
GeneralRe: Help on people posting comments on my website Pin
T. Cody23-Jul-09 15:09
T. Cody23-Jul-09 15:09 
GeneralRe: Help on people posting comments on my website Pin
Richard Andrew x6423-Jul-09 15:11
professionalRichard Andrew x6423-Jul-09 15:11 
GeneralRe: Help on people posting comments on my website Pin
CaptainSeeSharp23-Jul-09 15:40
CaptainSeeSharp23-Jul-09 15:40 
Questionurgent help needed asp.net C# code error [modified] Pin
solo_gaurav23-Jul-09 10:20
solo_gaurav23-Jul-09 10:20 
hey im using sql server connection with oledb provider to access database..previously it was ms access file .. now i am try switched to sql database.. here is the C# code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Imaging;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.DataVisualization.Charting;
using System.Data.OleDb;

namespace System.Web.UI.DataVisualization.Charting.Samples
{
	/// <summary>
	/// Summary description for ImageMapCustom.
	/// </summary>
	public partial class DataBindSeriesByRows : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// resolve the address to the Access database
			//string fileNameString = this.MapPath(".");
			///fileNameString += "..\\..\\..\\..\\data\\chartdata.mdb";

			// initialize a connection string    
            string myConnectionString = "Provider=SQLNCLI.1;Data Source=.;Integrated Security=SSPI;Initial Catalog=abc";
	
			// define the database query	
			string mySelectQuery="SELECT * FROM SALESCOUNTS;";

			// create a database connection object using the connection string	
			OleDbConnection myConnection = new OleDbConnection(myConnectionString);
			
			// create a database command on the connection using query	
			OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
			
			// open the connection	
			myCommand.Connection.Open();
			
			// Initializes a new instance of the OleDbDataAdapter class
			OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
			myDataAdapter.SelectCommand = myCommand;

			// Initializes a new instance of the DataSet class
			DataSet myDataSet = new DataSet();

			// Adds rows in the DataSet
			myDataAdapter.Fill(myDataSet, "Query");
			
			
			foreach(DataRow row in myDataSet.Tables["Query"].Rows)
			{
				// for each Row, add a new series
				string seriesName = row["SalesRep"].ToString();
				Chart1.Series.Add(seriesName);
				Chart1.Series[seriesName].ChartType = SeriesChartType.Line;
				Chart1.Series[seriesName].BorderWidth = 2;
				Chart1.Series[seriesName].ShadowOffset = 2;


				for(int colIndex = 1; colIndex < myDataSet.Tables["Query"].Columns.Count; colIndex++)
				{
					// for each column (column 1 and onward), add the value as a point
					string columnName = myDataSet.Tables["Query"].Columns[colIndex].ColumnName;
					int YVal = (int) row[columnName];////// ERRROR IN THIS LINE

					Chart1.Series[seriesName].Points.AddXY(columnName, YVal);
				}
			}

			DataGrid.DataSource = myDataSet;
			DataGrid.DataBind();

			// Closes the connection to the data source. This is the preferred 
			// method of closing any open connection.
			myCommand.Connection.Close();

		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion

		
	}
}

==============================================================

IM getting this error on running this code..:
Server Error in '/DataBindSeriesByRows' Application.
Specified cast is not valid. 
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.InvalidCastException: Specified cast is not valid.

Source Error: 

Line 68: 					// for each column (column 1 and onward), add the value as a point
Line 69: 					string columnName = myDataSet.Tables["Query"].Columns[colIndex].ColumnName;
Line 70: 					int YVal = (int) row[columnName];
Line 71: 
Line 72: 					Chart1.Series[seriesName].Points.AddXY(columnName, YVal);


Source File: c:\Documents and Settings\gauravk\My Documents\WebSamples\WebSamples\WorkingWithData\DataBinding\DataBindSeriesByRows\DataBindSeriesByRows.aspx.cs    Line: 70 

Stack Trace: 

[InvalidCastException: Specified cast is not valid.]
   System.Web.UI.DataVisualization.Charting.Samples.DataBindSeriesByRows.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\gauravk\My Documents\WebSamples\WebSamples\WorkingWithData\DataBinding\DataBindSeriesByRows\DataBindSeriesByRows.aspx.cs:70
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053



plz help buddiess... i'll be very grateful.. thanks in advance Smile | :)

modified on Thursday, July 23, 2009 5:00 PM

AnswerRe: urgent help needed asp.net C# code error Pin
Abhijit Jana23-Jul-09 10:22
professionalAbhijit Jana23-Jul-09 10:22 
AnswerRe: urgent help needed asp.net C# code error Pin
solo_gaurav23-Jul-09 10:53
solo_gaurav23-Jul-09 10:53 
GeneralRe: urgent help needed asp.net C# code error Pin
Abhijit Jana23-Jul-09 10:57
professionalAbhijit Jana23-Jul-09 10:57 
GeneralRe: urgent help needed asp.net C# code error Pin
solo_gaurav23-Jul-09 11:05
solo_gaurav23-Jul-09 11:05 
GeneralRe: urgent help needed asp.net C# code error Pin
Abhijit Jana23-Jul-09 11:26
professionalAbhijit Jana23-Jul-09 11:26 
GeneralRe: urgent help needed asp.net C# code error Pin
PDTUM23-Jul-09 11:36
PDTUM23-Jul-09 11:36 
AnswerRe: urgent help needed asp.net C# code error [modified] Pin
Abhijit Jana23-Jul-09 11:09
professionalAbhijit Jana23-Jul-09 11:09 
GeneralRe: urgent help needed asp.net C# code error Pin
solo_gaurav23-Jul-09 11:15
solo_gaurav23-Jul-09 11:15 
QuestionJust trying to get simple app to run on the server Pin
Jeffrey Webster23-Jul-09 9:10
Jeffrey Webster23-Jul-09 9:10 
AnswerRe: Just trying to get simple app to run on the server Pin
David Mujica23-Jul-09 9:32
David Mujica23-Jul-09 9:32 
GeneralRe: Just trying to get simple app to run on the server Pin
Jeffrey Webster23-Jul-09 9:48
Jeffrey Webster23-Jul-09 9:48 
GeneralRe: Just trying to get simple app to run on the server Pin
Abhijit Jana23-Jul-09 9:59
professionalAbhijit Jana23-Jul-09 9:59 
GeneralRe: Just trying to get simple app to run on the server Pin
Jeffrey Webster23-Jul-09 10:24
Jeffrey Webster23-Jul-09 10:24 
GeneralRe: Just trying to get simple app to run on the server Pin
Abhijit Jana23-Jul-09 10:28
professionalAbhijit Jana23-Jul-09 10:28 
AnswerRe: Just trying to get simple app to run on the server Pin
Abhijit Jana23-Jul-09 9:37
professionalAbhijit Jana23-Jul-09 9:37 
GeneralRe: Just trying to get simple app to run on the server Pin
Jeffrey Webster23-Jul-09 10:17
Jeffrey Webster23-Jul-09 10:17 
GeneralRe: Just trying to get simple app to run on the server Pin
Abhijit Jana23-Jul-09 10:20
professionalAbhijit Jana23-Jul-09 10:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.