bripoin Posted May 26, 2006 Posted May 26, 2006 Okay...I've modified my original code so that I now have two datagrids. One is for the information that I am pulling from the database that is constant for every instance of information. The other is for information that varies from instance to instance. I've gotten the first database to where it is pulling the correct information and I wrote the code so that it filters the info for the second datagrid by using the "PruID" pulled into the first datagrid. However, when I run the code, I get a blank datagrid for the second one. Here is the code for the click event: Try Me.SqlSelectCommand1.Parameters.Add("@PermitNum", SqlDbType.VarChar) Me.SqlSelectCommand1.Parameters("@PermitNum").Value = TextBox1.Text Me.LoadDataSet31() Me.DataGrid1.SelectedIndex = -1 Me.DataGrid1.DataBind() Me.SqlSelectCommand2.Parameters.Add("@PruID", SqlDbType.Variant) Me.SqlSelectCommand2.Parameters("@PruID").Value = Me.DataGrid1.DataKeyField Me.LoadDataSet51() Me.DataGrid2.SelectedIndex = -1 Me.DataGrid2.DataBind() Catch eLoad As System.Exception Me.Response.Write(eLoad.Message) End Try Any ideas as to why this is happening? Quote
Diesel Posted May 26, 2006 Posted May 26, 2006 Assuming that the select command are bound to the correct datasets, and the datasets to the correct grids... Make sure Me.DataGrid1.DataKeyField is returning the right value Me.SqlSelectCommand2.Parameters.Add("@PruID", SqlDbType.Variant) set the PruID var to the correct type Quote
bripoin Posted May 26, 2006 Author Posted May 26, 2006 I tried Text and got: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. I tried VarChar and got: Syntax error converting the varchar value 'PruID' to a column of data type int. I tried Int and got: Input string was not in a correct format. Those last two results lead me to believe that it's grabbing the column heading with in the DataGrid instead of the information that was pulled from the database. Quote
Diesel Posted May 26, 2006 Posted May 26, 2006 Debug it, what is the value of Me.DataGrid1.DataKeyField Change Me.SqlSelectCommand2.Parameters("@PruID").Value = Me.DataGrid1.DataKeyField to Me.SqlSelectCommand2.Parameters("@PruID").Value = int.Parse(Me.DataGrid1.DataKeyField) Quote
bripoin Posted May 29, 2006 Author Posted May 29, 2006 When I try that I get "Overload resolution failed becasue no accessible "Int" accepts this number of arguments." The valule of the DataKeyField is a String that is pulled from the database with the first SQL Select command. Quote
bripoin Posted May 31, 2006 Author Posted May 31, 2006 Alright, I'm trying something different now. I'm using a Master and a Detail grid to show this information in two different datagrids. I'm using the same parameter of "@PermitNum" to select the information for the Master grid, but I don't know if it's acctually using this parameter. Mainly because the application "times out" before it can ever load anything. Here's the code: 'SqlSelectCommand1 ' Me.SqlSelectCommand1.CommandText = "SELECT tblPRUMaster.PruID, tblPRUMaster.PruNumber, tblPRUMaster.PruName, tblPRUMa" & _ "ster.NorthOrSouth, tblPRUMaster.PermitNo FROM tblPRUMaster INNER JOIN tblPRUProd" & _ "uction ON tblPRUMaster.PruID = tblPRUProduction.PruID WHERE (tblPRUMaster.PermitNo = @PermitNum)" Me.SqlSelectCommand1.Connection = Me.SqlConnection1 The code for the Button click: Try Me.SqlSelectCommand1.Parameters.Add("@PermitNum", SqlDbType.VarChar) Me.SqlSelectCommand1.Parameters("@PermitNum").Value = TextBox1.Text Me.LoadDataSet() Me.masterDataGrid.SelectedIndex = -1 Me.masterDataGrid().DataBind() Catch eLoad As System.Exception Me.Response.Write(eLoad.Message) End Try Quote
bungpeng Posted October 26, 2006 Posted October 26, 2006 Overload resolution failed... (Convert from 1.1 to 2.0) sorry, wrong post Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.