Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 5th, 2005, 7:22 AM   #1
Samsonite
Newbie
 
Samsonite's Avatar
 
Join Date: Mar 2005
Posts: 15
Rep Power: 0 Samsonite is on a distinguished road
Input String incorrect?

Hey guys sorry if this is really simple for you but i keep getting this stupid error of Input string incorect and highlights this line

this.oleDBSelectCommandSearchGenre.Parameters.Add("@TableNo",System.Data.OleDb.OleDbType.Integer).Value = int.Parse(this.oleDBSelectCommandSearchGenre.ToString());
this.oleDBDataAdapterSearch.Fill this.oleDBDataSetSearch.Tables["tblGenre"]);

this is the code i have

 
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication1
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		System.Data.OleDb.OleDbConnection oleDBConnectionSearch;
		System.Data.OleDb.OleDbDataAdapter oleDBDataAdapterSearch;
		System.Data.DataSet oleDBDataSetSearch;
		System.Data.DataTable oleDBDataTableGenre;
		System.Data.OleDb.OleDbCommand oleDBSelectCommandSearchGenre;

		System.Data.DataTable oleDBDataTableTitles;
		System.Data.OleDb.OleDbCommand oleDBSelectCommandSearchTitles;
		private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
		private System.Data.OleDb.OleDbConnection oleDbConnection1;
		private System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
		private System.Data.OleDb.OleDbCommand oleDbSelectCommand2;
		private System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
		private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
		private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
		private WindowsApplication1.DataSet1 dataSet11;
		private System.Windows.Forms.ListBox listBox1;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.DataGrid dataGrid1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			this.oleDBConnectionSearch = new System.Data.OleDb.OleDbConnection();
			this.oleDBConnectionSearch.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\assignment.mdb";
			this.oleDBDataAdapterSearch = new System.Data.OleDb.OleDbDataAdapter();
			this.oleDBDataSetSearch = new System.Data.DataSet("oleDBDataSetSearch");
			this.oleDBDataTableGenre = new System.Data.DataTable();
			this.oleDBSelectCommandSearchGenre = new System.Data.OleDb.OleDbCommand();

			//this.cbxSelectTable.BeginUpdate();
			//for (int fIndex = 1; fIndex <= 18; fIndex++)
			//{
			//	this.cbxSelectTable.Items.Add(fIndex);
			//}
			//this.cbxSelectTable.EndUpdate();
			//oleDbDataAdapter1.Fill(dataSet11);

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
			this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
			this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
			this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
			this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
			this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
			this.dataSet11 = new WindowsApplication1.DataSet1();
			this.listBox1 = new System.Windows.Forms.ListBox();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// oleDbDataAdapter1
			// 
			this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
			this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
			this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
			this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																										new System.Data.Common.DataTableMapping("Table", "All", new System.Data.Common.DataColumnMapping[] {
																																																			   new System.Data.Common.DataColumnMapping("Genre", "Genre"),
																																																			   new System.Data.Common.DataColumnMapping("Name", "Name"),
																																																			   new System.Data.Common.DataColumnMapping("ID", "ID")})});
			this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
			// 
			// oleDbDeleteCommand1
			// 
			this.oleDbDeleteCommand1.CommandText = "DELETE FROM [All] WHERE (ID = ?) AND (Genre = ? OR ? IS NULL AND Genre IS NULL) A" +
				"ND (Name = ? OR ? IS NULL AND Name IS NULL)";
			this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Genre", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Genre", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Genre1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Genre", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Name", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Name", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Name1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Name", System.Data.DataRowVersion.Original, null));
			// 
			// oleDbConnection1
			// 
			this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=0;Data Source=""J:\Assignment.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";
			// 
			// oleDbInsertCommand1
			// 
			this.oleDbInsertCommand1.CommandText = "INSERT INTO [All] (Genre, Name) VALUES (?, ?)";
			this.oleDbInsertCommand1.Connection = this.oleDbConnection1;
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Genre", System.Data.OleDb.OleDbType.VarWChar, 50, "Genre"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Name", System.Data.OleDb.OleDbType.VarWChar, 50, "Name"));
			// 
			// oleDbSelectCommand1
			// 
			this.oleDbSelectCommand1.CommandText = "SELECT Genre, Name, ID FROM [All]";
			this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
			// 
			// oleDbUpdateCommand1
			// 
			this.oleDbUpdateCommand1.CommandText = "UPDATE [All] SET Genre = ?, Name = ? WHERE (ID = ?) AND (Genre = ? OR ? IS NULL A" +
				"ND Genre IS NULL) AND (Name = ? OR ? IS NULL AND Name IS NULL)";
			this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Genre", System.Data.OleDb.OleDbType.VarWChar, 50, "Genre"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Name", System.Data.OleDb.OleDbType.VarWChar, 50, "Name"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Genre", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Genre", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Genre1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Genre", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Name", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Name", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Name1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Name", System.Data.DataRowVersion.Original, null));
			// 
			// dataSet11
			// 
			this.dataSet11.DataSetName = "DataSet1";
			this.dataSet11.Locale = new System.Globalization.CultureInfo("en-US");
			// 
			// listBox1
			// 
			this.listBox1.DataSource = this.dataSet11.All;
			this.listBox1.DisplayMember = "Name";
			this.listBox1.Location = new System.Drawing.Point(392, 88);
			this.listBox1.Name = "listBox1";
			this.listBox1.Size = new System.Drawing.Size(176, 173);
			this.listBox1.TabIndex = 1;
			// 
			// comboBox1
			// 
			this.comboBox1.Location = new System.Drawing.Point(400, 24);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(168, 21);
			this.comboBox1.TabIndex = 2;
			this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
			// 
			// dataGrid1
			// 
			this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.DataSource = this.dataSet11.All;
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(0, 0);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(384, 280);
			this.dataGrid1.TabIndex = 0;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(576, 273);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.listBox1);
			this.Controls.Add(this.dataGrid1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
		private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			// call another select command
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			// This is where fill command should occurr
			// select distinct genre from ????
			this.comboBox1.Items.Clear();

			this.oleDBDataSetSearch.Tables.Clear();
			this.oleDBDataSetSearch.Tables.Add("tblGenre");
			this.oleDBDataSetSearch.Clear();
			this.oleDBDataSetSearch.CaseSensitive = false;

			this.oleDBDataAdapterSearch.SelectCommand = this.oleDBSelectCommandSearchGenre;
			this.oleDBSelectCommandSearchGenre.CommandText = "Select distinct Genre FROM [All]";
			this.oleDBSelectCommandSearchGenre.CommandType = System.Data.CommandType.Text;
			this.oleDBSelectCommandSearchGenre.Connection = this.oleDBConnectionSearch;

			this.oleDBSelectCommandSearchGenre.Parameters.Clear();
			this.oleDBSelectCommandSearchGenre.Parameters.Add("@TableNo",System.Data.OleDb.OleDbType.Integer).Value = int.Parse(this.oleDBSelectCommandSearchGenre.ToString());
			this.oleDBDataAdapterSearch.Fill(this.oleDBDataSetSearch.Tables["tblGenre"]);
			this.comboBox1.DataSource = this.oleDBDataSetSearch.Tables["tblGenre"];

			//for (int fIndex = 0; fIndex < this.oleDBDataSetShowOrder.Tables["tblOrders"].Rows.Count; fIndex++)
			//{
			//	this.lvwShowOrder.Items.Add(this.oleDBDataSetShowOrder.Tables["tblOrders"].Rows[fIndex]["Dish_Name"].ToString());
			//	this.lvwShowOrder.Items[fIndex].SubItems.Add(this.oleDBDataSetShowOrder.Tables["tblOrders"].Rows[fIndex]["Quantity"].ToString());
			//}

		}

	}
}
Samsonite is offline   Reply With Quote
Old Apr 9th, 2005, 9:18 PM   #2
anandt4u
Newbie
 
Join Date: Feb 2005
Posts: 22
Rep Power: 0 anandt4u is on a distinguished road
can you post your table schema???
anandt4u is offline   Reply With Quote
Old Apr 11th, 2005, 1:06 AM   #3
Samsonite
Newbie
 
Samsonite's Avatar
 
Join Date: Mar 2005
Posts: 15
Rep Power: 0 Samsonite is on a distinguished road
Dont worry about it i fixed it all now
Samsonite is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:08 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC