Click here to Skip to main content
15,922,325 members
Home / Discussions / C#
   

C#

 
AnswerRe: retrieving command line arguments from a file Pin
Judah Gabriel Himango21-Jun-06 11:57
sponsorJudah Gabriel Himango21-Jun-06 11:57 
QuestionHow can I send to back a mdi child window? Pin
User 309585921-Jun-06 10:43
User 309585921-Jun-06 10:43 
Questiondata unbinding relate...urgnt plzz Pin
r_e_h_a_n21-Jun-06 10:33
r_e_h_a_n21-Jun-06 10:33 
AnswerRe: data unbinding relate...urgnt plzz Pin
Edbert P21-Jun-06 14:50
Edbert P21-Jun-06 14:50 
QuestionBiztalk 2004: How to pass database facts from C# code? Pin
pankazmittal21-Jun-06 10:25
pankazmittal21-Jun-06 10:25 
QuestionSQL Express 2005 Dumper for SQL Server 2005 Pin
emran83421-Jun-06 10:14
emran83421-Jun-06 10:14 
AnswerRe: SQL Express 2005 Dumper for SQL Server 2005 Pin
Mark Tutt21-Jun-06 10:50
Mark Tutt21-Jun-06 10:50 
QuestionData Adapter passing by reference to stored procedure Pin
leckey21-Jun-06 9:07
leckey21-Jun-06 9:07 
My title probably doesn't quite explain my problem. I found some code for a fully editable grid. It was pointing to the Northwind database, pulling employee information. Okay, no problem. So now I am trying to update the code to fit what I need and I'm getting an error that I can't seem to fix.

Here is the ORIGINAL BindData code:
private void BindData()<br />
		{<br />
			 ds = new DataSet();<br />
			ds= SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetEmployees", null);<br />
			Session["ds"]=ds;<br />
			dt = ds.Tables[0];<br />
			Session["dt"]=dt;<br />
			DataGrid1.DataSource=dt;<br />
			DataGrid1.DataBind();<br />
			<br />
		}


This code uses a Microsoft SQLHelper.cs class.

Okay, so I created a stored proc called GetPartInfo. Basically there is a text box the user enters a part number, clicks a button and then the grid populates. Based on help from a couple of expert members from CodeProject this what I used to have...
private void BindData2()<br />
		{<br />
			strPartNumberInputReference = txtPartNumberInput.Text;<br />
			string SQLString = "SELECT c.cost, ct.Description AS ctDescription, p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath FROM costs c INNER JOIN Parts p ON c.PartID = p.Id INNER JOIN PartTypes pt on pt.ID = p.PartTypeID LEFT JOIN DraftingData dd on dd.PartID = p.ID LEFT JOIN CostTypes ct on ct.Id = c.CostTypeId WHERE p.PartNumber = @PartID"; <br />
			<br />
			SqlCommand cmd = new SqlCommand();<br />
			cmd.Connection = new SqlConnection(strConnectSQL);<br />
			cmd.CommandText = SQLString;<br />
			cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
			SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
			adapter.Fill(ds);<br />
<br />
			<br />
			dgParts2.DataSource = ds;<br />
			dgParts2.DataBind();<br />
			txtPartNumberInput.Text = "";<br />
			<br />
		<br />
		}


As you can see I am passing @PartID.

So in my stored procedure I have...
CREATE PROCEDURE [dbo].[GetPartInfo]<br />
@PartID int AS<br />
SELECT c.cost, ct.Description AS ctDescription, p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath<br />
FROM costs c INNER JOIN Parts p ON c.PartID = p.Id <br />
INNER JOIN PartTypes pt on pt.ID = p.PartTypeID <br />
LEFT JOIN DraftingData dd on dd.PartID = p.ID LEFT JOIN CostTypes ct on ct.Id = c.CostTypeId <br />
WHERE p.PartNumber = @PartID;<br />
GO


Still trying to pass @PartID.

When I tried changing the line...
ds= SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetEmployees", null);to

ds= SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetPartInfo", ("@PartID"));

I get the error that my Input string was not in correct format.
Here is the code for ExecuteDataset:
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)<br />
		{<br />
			//create & open a SqlConnection, and dispose of it after we are done.<br />
			using (SqlConnection cn = new SqlConnection(connectionString))<br />
			{<br />
				cn.Open();<br />
<br />
				//call the overload that takes a connection in place of the connection string<br />
				return ExecuteDataset(cn, commandType, commandText, commandParameters);<br />
			}<br />
		}


I've tried a bunch of different things and I still get the error. How do I fix this?

Thanks again for all those who help me on this board. Sucks being a newbie.
AnswerRe: Data Adapter passing by reference to stored procedure Pin
Not Active21-Jun-06 9:25
mentorNot Active21-Jun-06 9:25 
GeneralRe: Data Adapter passing by reference to stored procedure [modified] Pin
leckey21-Jun-06 9:28
leckey21-Jun-06 9:28 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
ashishinfra21-Jun-06 20:07
ashishinfra21-Jun-06 20:07 
AnswerRe: Data Adapter passing by reference to stored procedure Pin
Josh Smith21-Jun-06 9:43
Josh Smith21-Jun-06 9:43 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
leckey21-Jun-06 9:47
leckey21-Jun-06 9:47 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
Josh Smith21-Jun-06 10:06
Josh Smith21-Jun-06 10:06 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
leckey21-Jun-06 10:17
leckey21-Jun-06 10:17 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
Josh Smith21-Jun-06 10:25
Josh Smith21-Jun-06 10:25 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
leckey21-Jun-06 10:39
leckey21-Jun-06 10:39 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
Josh Smith21-Jun-06 10:44
Josh Smith21-Jun-06 10:44 
QuestionPaint Event Handler Pin
ZeAugusto21-Jun-06 7:23
ZeAugusto21-Jun-06 7:23 
AnswerRe: Paint Event Handler Pin
Josh Smith21-Jun-06 7:25
Josh Smith21-Jun-06 7:25 
GeneralRe: Paint Event Handler Pin
ZeAugusto21-Jun-06 7:42
ZeAugusto21-Jun-06 7:42 
GeneralRe: Paint Event Handler [modified] Pin
led mike21-Jun-06 8:01
led mike21-Jun-06 8:01 
GeneralRe: Paint Event Handler Pin
Josh Smith21-Jun-06 8:06
Josh Smith21-Jun-06 8:06 
GeneralRe: Paint Event Handler Pin
Jun Du21-Jun-06 9:05
Jun Du21-Jun-06 9:05 
GeneralRe: Paint Event Handler Pin
ZeAugusto21-Jun-06 12:05
ZeAugusto21-Jun-06 12:05 

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.