Gridview To Database Rpoblem?

Mar 3, 2008

Hi
I have page where gridview is loaded from the Excel sheet and when the button is clicked it must insert those values in to the table and  ........the code for loading the gridview from the excel if working fine but when i click on the Insert button i am getting the errors the code behind for button is as follows:
  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
' Dim constr As String = "...." 'your connection string
' Dim connection As SqlConnection = New SqlConnection(constr)
Dim i As Integer
Dim ia As Integer = ds.Tables("table").Rows.Count - 1
For i = 0 To ia
Dim one As String = ds.Tables("table").Rows(i)("Column1")
Dim two As String = ds.Tables("table").Rows(i)("Column2")
Dim three As String = ds.Tables("table").Rows(i)("Column3")
Dim four As String = ds.Tables("table").Rows(i)("Column4")
Dim five As String = ds.Tables("table").Rows(i)("Column5")
Dim six As String = ds.Tables("table").Rows(i)("Column6")
Dim seven As String = ds.Tables("table").Rows(i)("Column7")
Dim eight As String = ds.Tables("table").Rows(i)("Column8")
Dim nine As String = ds.Tables("table").Rows(i)("Column9")
Dim ten As String = ds.Tables("table").Rows(i)("Column10")

'get every cell content of this row like the above line
' Dim sqlsel As String = "insert into table('ID') values('" + one + "')"
Dim cmdSavegrd As OdbcCommand = New OdbcCommand("INSERT INTO gd_master VALUES( " & one & ",'" & two & "', '" & three & "'," & four & ",'" & five & "'," & six & "," & seven & ",'" & eight & "'," & nine & ",'" & ten & "')", con)
'Dim sdc As SqlCommand = New SqlCommand(sqlsel, con)
' sdc.CommandType = CommandType.Text
con.Open()
'sdc.ExecuteNonQuery()
cmdSavegrd.ExecuteReader()
con.Close()

Next
End Sub
  
 
The Error i am getting is as follows .........
"Object reference not set to an instance of an object. "
Please can any help me in this?>? 

View 2 Replies


ADVERTISEMENT

Want Error Message To Appear When No Database Results Were Returned In GridView, Also Other GridView Issues.

Jun 12, 2008

Hi, I am seeking a hopefully easy solution to spit back an error message when a user receives no results from a SQL server db with no results. My code looks like this What is in bold is the relevant subroutine for this problem I'm having.   Partial Class collegedb_Default Inherits System.Web.UI.Page Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click SqlDataSource1.SelectCommand = "SELECT * FROM [college_db] WHERE [name] like '%" & textbox1.Text & "%'" SqlDataSource1.DataBind() If (SqlDataSource1 = System.DBNull) Then no_match.Text = "Your search returned no results, try looking manually." End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load SqlDataSource1.SelectCommand = "SELECT * FROM [college_db] ORDER BY [name]" SqlDataSource1.DataBind() End Sub Protected Sub reset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles reset.Click SqlDataSource1.SelectCommand = "SELECT * FROM [college_db] ORDER BY [name]" SqlDataSource1.DataBind() End SubEnd Class  I'm probably doing this completely wrong, I'm a .net newb. Any help would be appreciated. Basically I have GridView spitting out info from a db upon Page Load, but i also have a search bar above that. The search function works, but when it returns nothing, I want an error message to be displayed. I have a label setup called "no_match" but I'm getting compiler errors. Also, next to the submit button, I also have another button (Protected sub reset) that I was hoping to be able to return all results back on the page, similar to if a user is just loading the page fresh. I'd think that my logic would be OK, by just repeating the source code from page_load, but that doens't work.The button just does nothing. One final question, unrelated. After I set this default.aspx page up, sorting by number on the bottom of gridview, ie. 1,2,3,4, etc, worked fine. But now that paging feature, as long with the sorting headers, don't work! I do notice on the status bar in the browser, that I receive an error that says, "error on page...and it referers to javascript:_doPostBack('GridView1, etc etc)...I have no clue why this happened. Any help would be appreciated, thanks! 

View 2 Replies View Related

7.0 Back Up Rpoblem

Oct 23, 2001

I set up a maintenance plan for a 15 gig database that performs a complete database back up daily at 12:10 a.m. with transaction log back ups hourly from 6 am to 11:00p.m. Everything works fine for the transaction logs, but I seem to have problems with the full back up on occassion. Both processes were set up to remove any back ups older than 1 day old. The full back up will not delete the previous back ups the majority of the time which leads to a lack of disk space and the back up failing if it is not monitored well. Any suggestions would be appreciated. Thanks.

View 3 Replies View Related

Search Database And Display In Gridview

Feb 23, 2008

I'm trying to do a search but it seems like it couldnt get the text in my text book and run the command. Can anyone help me here?Function searchBook(ByVal booking_id As Integer) As System.Data.DataSet
Dim search As Integer = txtSearch.Text
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='Speedo'"Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [booking].* FROM [booking] WHERE [booking].[booking_id] LIKE '%1%'"Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnectionDim dbParam_booking_id As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_booking_id.ParameterName = "@booking_id"
dbParam_booking_id.Value = booking_id
dbParam_booking_id.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_booking_id)Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommandDim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)Return dataSet
End Function
 Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
' If Not Page.IsPostBack Then
'Dim search As String = txtSearch.Text
'MsgBox(search)
If ddSearchCat.SelectedValue = "booking" ThenMsgBox("you have selected booking")
GVSearch.DataSource = searchBook(txtSearch.Text)
GVSearch.DataBind()
ElseIf ddSearchCat.SelectedValue = "Log" ThenMsgBox("you have selected Log")
GVSearch.DataSource = searchLog(txtSearch.Text)
GVSearch.DataBind()
ElseIf ddSearchCat.SelectedValue = "UserName" ThenMsgBox("you have selected UserName")
GVSearch.DataSource = searchUserName(txtSearch.Text)MsgBox("HELLO IN GRID")
GVSearch.DataBind()
GVSearch.Visible = TrueMsgBox("out of grid")
End If
'End If
End Sub

View 3 Replies View Related

Display Data From A Database Without Using Gridview Etc.

Mar 19, 2008

I have a webform that I am wanting to display data from a database. Right now I am using the gridview but for future purposes when it comes to maintenance what would be the easiest way to do updates? For example, if I add a new record into the database I would like the webform to automatically update itself to show all the records including the new record I added. Do I need to use a "table" and somehow connect it to a database? Do any stored procedures need to be created? Suggestions/ideas/codes help help help would be verrrry much appreciated!!! Also I am using MS Server 2003 and C# as the programming language. Thank you!!!!

View 9 Replies View Related

Error While Using Database Procedure In A Gridview Control

Dec 19, 2006

Dear Forum,
I have a gridview control  which is associated to a storedprocedure  with a parameter(Customer Number) to be supplied.  In the Define Custom Statement or stored procedure section  I selected stored procedure and selected the stored procedure.  The Define Parameter window I defaulted the Parameter Source as 'none' and default value as '%'.   In the next screen, I do a test query which retuns the following error
There was an error executing the query.  Please check the syntax of the command and if present, the type and values of the parameters  and ensure that they are correct.
[Error 42000] [Microsoft][ODBC SQL Server Drive][SQL Server] Procedure 'SP_TransactionDetails' expects parameter '@cnum' which was not supplied.
I am using SQL server studio  2005 version2.0. 
But the same procedure, if I use as SQL Statement, it works.
Can somebody help me.
Thanks,
Hidayath 

View 3 Replies View Related

How Too Show Stored Image From Database To Gridview Column

Mar 22, 2008

Dear people,
When i test my page for uploading image too my sql database everthing goes ok (i think) en when i look into my database table i see 3 colums filled
1 column with: Image_title    text
1 column with:Image_stream  <binary data>
1 column with image_type  image/pjpeg
How can i show this image in a gridview column..... i have search for this problem but non of them i find i can use because its a too heavy script, or something i dont want.
Is there a helping hand
Below is the script for uploading the image.....and more
 
 1
2 Imports System.Data
3 Imports System.Data.SqlClient
4 Imports System.IO
5
6 Partial Class Images_toevoegen
7 Inherits System.Web.UI.Page
8
9
10 Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
11
12 Dim imageSize As Int64
13 Dim imageType As String
14 Dim imageStream As Stream
15
16 ' kijkt wat de groote van de image is
17 imageSize = fileImgUpload.PostedFile.ContentLength
18
19 ' kijk welke type image het is
20 imageType = fileImgUpload.PostedFile.ContentType
21
22 ' Reads the Image stream
23 imageStream = fileImgUpload.PostedFile.InputStream
24
25 Dim imageContent(imageSize) As Byte
26 Dim intStatus As Integer
27 intStatus = imageStream.Read(imageContent, 0, imageSize)
28
29 ' connectie maken met de database
30 Dim myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("Personal").ConnectionString)
31 Dim myCommand As New SqlCommand("insert into tblMateriaal(Image_title,Image_stream,Image_type,ArtikelGroep,ArtikelMaat,Aantal,Vestiging,ArtikelNaam,ContactPersoon,DatumOnline) values(@Image_title,@Image_stream,@Image_type,@ArtikelGroep,@ArtikelMaat,@Aantal,@Vestiging,@ArtikelNaam,@ContactPersoon,@DatumOnline)", myConnection)
32
33 ' Mark the Command as a Text
34 myCommand.CommandType = CommandType.Text
35
36 ' geef alle parameters mee aan het command
37 Dim Image_title As New SqlParameter("@Image_title", SqlDbType.VarChar)
38 Image_title.Value = txtImgTitle.Text
39 myCommand.Parameters.Add(Image_title)
40
41 Dim Image_stream As New SqlParameter("@Image_stream", SqlDbType.Image)
42 Image_stream.Value = imageContent
43 myCommand.Parameters.Add(Image_stream)
44
45 Dim Image_type As New SqlParameter("@Image_type", SqlDbType.VarChar)
46 Image_type.Value = imageType
47 myCommand.Parameters.Add(Image_type)
48
49 Dim ArtikelGroep As New SqlParameter("@ArtikelGroep", System.Data.SqlDbType.NVarChar)
50 ArtikelGroep.Value = ddl1.SelectedValue
51 myCommand.Parameters.Add(ArtikelGroep)
52
53 Dim ArtikelMaat As New SqlParameter("@ArtikelMaat", System.Data.SqlDbType.NVarChar)
54 ArtikelMaat.Value = ddl2.SelectedValue
55 myCommand.Parameters.Add(ArtikelMaat)
56
57
58 Dim Aantal As New SqlParameter("@Aantal", System.Data.SqlDbType.NVarChar)
59 Aantal.Value = ddl3.SelectedValue
60 myCommand.Parameters.Add(Aantal)
61
62 Dim Vestiging As New SqlParameter("@Vestiging", System.Data.SqlDbType.NVarChar)
63 Vestiging.Value = ddl4.SelectedValue
64 myCommand.Parameters.Add(Vestiging)
65
66 Dim ArtikelNaam As New SqlParameter("@ArtikelNaam", System.Data.SqlDbType.NVarChar)
67 ArtikelNaam.Value = tb6.Text
68 myCommand.Parameters.Add(ArtikelNaam)
69
70 Dim ContactPersoon As New SqlParameter("@ContactPersoon", System.Data.SqlDbType.NVarChar)
71 ContactPersoon.Value = tb1.Text
72 myCommand.Parameters.Add(ContactPersoon)
73
74 Dim DatumOnline As New SqlParameter("@DatumOnline", System.Data.SqlDbType.NVarChar)
75 DatumOnline.Value = tb2.Text
76 myCommand.Parameters.Add(DatumOnline)
77
78 Try
79 myConnection.Open()
80 myCommand.ExecuteNonQuery()
81 myConnection.Close()
82
83 Response.Redirect("toevoegen.aspx")
84 Catch SQLexc As SqlException
85 Response.Write("Insert Failure. Error Details : " & SQLexc.ToString())
86 End Try
87
88
89 End Sub
90 End class
 

View 2 Replies View Related

Stored Procedure To Display The Relevant Data Of The IDs In The Database To A Gridview

Mar 7, 2008

Here is the Stored procedure 
ALTER procedure [dbo].[ActAuditInfo](@IndustryName nvarchar(50) output,@CompanyName nvarchar(50) output,@PlantName nvarchar(50) output,@GroupName nvarchar(50) output,@UserName nvarchar(50) output
)asbegindeclare @AuidtID as varchar(30)Select @IndustryName=Industry_Name from Industry whereIndustry.Ind_Id_PK =(Select Audit_Industry from Audits whereAd_ID_PK=@AuidtID)Select @CompanyName=Company_Name from Company whereCompany.Cmp_ID_PK =(Select Audit_Company from Audits whereAd_ID_PK=@AuidtID)Select @PlantName=Plant_Name from Plant where Plant.Pl_ID_PK=(Select Audit_Plant from Audits where Ad_ID_PK=@AuidtID)Select @GroupName=Groups_Name from Groups whereGroups.G_ID_PK =(Select Audit_Group from Audits whereAd_ID_PK=@AuidtID)Select @UserName=Login_Uname from RegistrationDetails whereRegistrationDetails.UID_PK =(Select Audit_Created_By fromAudits where Ad_ID_PK=@AuidtID)SELECT Ad_ID_PK, Audit_Name, @IndustryName, @CompanyName, @PlantName,@GroupName, Audit_Started_On, Audit_Scheduledto, @UserName FROMAudits where Audit_Status='Active'end
U can see here different parameters,my requirement is that iam havingID's of Industry,company,plant,group,username stored in a table calledPcra_Audits and i must display their related names in the front end.so this is the query iam using for that.
Data in the database:Commercial83312 2       2       2       1       1       InactiveHere u can see  2,2,2,1,1 these are the IDs ofindustry,company,plant,group and username and Commercial83312 is tehaudit ID.now i want to display this data in teh front end as i cannot displaythe IDs i am retrieving the names of the particular IDs from therelated tables.Like iam getting name of the IndustryID from Industry Table,in thesame way others too.when iam running this procedure iam getting the gridview blank.iam passing the output parameters:@IndustryName nvarchar(50) output,@CompanyName nvarchar(50) output,@PlantName nvarchar(50) output,@GroupName nvarchar(50) output,@UserName nvarchar(50) outputinto the function in the frontend and iam calling that into the pageload method.please help me with this.

View 1 Replies View Related

Gridview In Asp.net

Nov 29, 2006

Can I directly Save data to sqlserver 2005 using gridview in frontend?
 
How?
 
 

View 2 Replies View Related

GridView Help

Feb 4, 2007

Hi,
I use WVD and SQL Express 2005.
I have a table “SignIn� that one of fields inserted automatically by getdate()
And I have GridView that I use to display this table because I would like take advantage of GridView sorting and paging methods that are embedded in.
Currently I display all records at once.
 
My problem is how to make the GridView show today’s records only.
I tried this code below, but I get only this message “There are no data records to display.�
 
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:RC1 %>"
ProviderName="<%$ ConnectionStrings:RC1.ProviderName %>"
SelectCommand="SELECT [student_ID], [SignIn], [SignOut], [Location] FROM [Stud_data] WHERE (CONVERT(VARCHAR(10),[SignIn],101) = @SignIn)">
     <SelectParameters>
       <asp:QueryStringParameter Name="SignIn" QueryStringField="Format(Now, &quot;M/dd/yyyy&quot;)" Type="DateTime" />
     </SelectParameters>
</asp:SqlDataSource>
 
Help Please!
 

View 6 Replies View Related

Gridview

Apr 17, 2008

Hi
I have a business search box and gridview pair. When the user enters a business name, the search results are displayed. I also generate a "more information" link which takes the user to a new page, passing the business name ("memberId")to this page (see the template field below).
The problem I have is if the name contains a QUOTE (') or other special characters. The "memberId" is chopped off at the quote (e.g. "Harry's Store" is passed as "Harry").
Can anyone tell me a way around this please? Is there anything I can do with the Eval method?
Kind regards,
Garrett
 
<asp:TemplateField HeaderText="More Info">
<ItemTemplate>
<a href='member_page.aspx?memberId=<%# Eval("co_name") %>'>more</a>
</ItemTemplate>
<ItemStyle Font-Bold="False" />
</asp:TemplateField>

View 2 Replies View Related

???GridView

Mar 29, 2006

HiI need to add in gridview control  asp code "delete from t1 where id=@id1"how to declare @id1 because the server give me mistake down is the code of asp i use GridView how i can link @id with field there id???Thank u and have a nice daybest regardsthe code if u need it i use c#
<ASP:SQLDATASOURCE id=SqlDataSource1 <br ConnectionString="<%$ ConnectionStrings:libraryConnectionString %>" runat="server"><BR></ASP:SQLDATASOURCE></ASP:BOUNDFIELD>

View 1 Replies View Related

Datatable From Gridview

Aug 2, 2006

hi all
 
the usual way to bid a gridview is to data soursce
is there a way to do  the folowing , creat a data table from the gridview shown valus " currunt page "
 
thanks
 

View 1 Replies View Related

Gridview Sorting

Aug 17, 2006

I have a gridview that has AllowSorting="true" however I need to implement my own sorting because I have DateTime and Integer data types in several of the columns and I don't want an int column sorted like 1,12,2,23,3,34,4,45,5,56, etc.  So, I've added SortParameterName="sortBy" and adjusted my stored procedure to accept this.  For only ASC sorting, I've got
ORDER BY  CASE WHEN @sortBy='' THEN DateCreated END,  CASE WHEN @sortBy='DateCreated' THEN DateCreated END
and so on.  However, columns can also be sorted with DESC.  I tried CASE WHEN @sortBy='DateCreated DESC' THEN DateCreated DESC END, but I get a syntax error on DESC.  How can I do this?

View 2 Replies View Related

Gridview And DropDownList

Oct 18, 2006

Hello:I have add a DropDownList to my GridView and binded the dropdownlist to a field from a select statement in the SQLDataSource. I have EnabledEditing for my GridView. The GridView is populated with information from the select statement. Some of the information returned from the select statement is null. The field where the dropdownlist is binded it is null in some cases and does not have a value that is in the dropdownlist so I get and error when I attempt to do an update. 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value Is there a way to get around this besides initializing all the columns in the table that are going to be binded to a dropdownlist to a value in the dropdownlist?

View 1 Replies View Related

Gridview Search

Jan 15, 2007

I tried doing a text box search within Gridview. My code are as follows. However, when I clicked on the search button, nothing shown.
Any help would be appreciated. I'm using an ODBC connection to MySql database. Could it be due to the parameters not accepted in MySql?
 
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
 
           SqlDataSource1.SelectCommand = "SELECT * FROM carrier_list WHERE carrierName LIKE '%' + @carrierName + '%'"
 
End Sub
 
Sub doSearch(ByVal Source As Object, ByVal E As EventArgs)
GridViewCarrierList.DataSourceID = "SqlDataSource1"
GridViewCarrierList.DataBind()
 
End Sub
 
HTML CODES (Snippet)
<asp:Button ID="btnSearchCarrier" runat="server" onclick="doSearch" Text="Search" />
' Gridview<asp:GridView ID="GridViewCarrierList" runat="server" DataSourceID="SqlDataSource1" >
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT * FROM carrier_list">
</asp:SqlDataSource>
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>">
<SelectParameters>
<asp:ControlParameter ControlID="txtSearchCarrier" Name="carrierName" PropertyName="Text" Type="String"></asp:ControlParameter>
</SelectParameters>
 
</asp:SqlDataSource>

View 8 Replies View Related

GridView...Problem

Mar 29, 2007

I m creating the project in asp.net using c# and vb languages in 2005.I have used the asp standard controls(with table<td><tr>) and gridview to design the form.I m using sqldatasource to insert and  update data from sql server 2005.I have written the following code  <script runat="server">     Private  Sub Page_Load()        If Not Request.Form("SUBMIT") Is Nothing Then            srccompany.Insert()        End If    End Sub</script>   <asp:SqlDataSource        id="srccompany"        SelectCommand="SELECT * FROM companymaster"        InsertCommand="INSERT companymaster(companyname)           VALUES (@companyname)"      UpdateCommand="UPDATE companymaster SET companyname=@companyname WHERE companyid=1"       DeleteCommand="DELETE companymaster WHERE companyname=@companyname"        ConnectionString="<%$ ConnectionStrings:companymaster %>"       Runat="server"></asp:SqlDataSource>   <asp:GridView        id="GridCompanyMaster"        DataSourceID="srccompany"        Runat="server" />Please help me to insert the data in sql server.i m not been able to insert the data is there any problem in coding..Also i m not been able to edit the data and store back to sql server.Only i can do is i can view the contents in gridview Please give me some tips  

View 1 Replies View Related

SQL OutputCache GridView

Oct 24, 2007

I'm trying to cache the contents of a gridivew unless another page, or sorting method are being called.  I tried to use the VaryByParam method, but I'm not having any luck, I keep getting the same page sent back to me. Here's what my code looks like.
<%@ OutputCache Duration="180" VaryByParam="Page$, Sort$" %>
 Any help would be appreciated.
Stephen

View 2 Replies View Related

Gridview Sql Timeout

Dec 3, 2007

I have a simple gridview displaying data from an MSSQL server 2005. Every now and then I get a sql timeout error. Listed below. Can anyone explain why I am getting this error?  The connection pool is 100 and the timeout is set to 360.  I have checked to current connections in SQL and they never max over 23.  There are not locks in SQL when the problem occurs. The query is a stored procedure in sql and when sent sample data it normally takes about 5 seconds.
 
 Event code: 3005 Event message: An unhandled exception has occurred. Event time: 12/3/2007 9:46:37 PM Event time (UTC): 12/4/2007 3:46:37 AM Event ID: 140501f9a7744dfea2e445ed00939e44 Event sequence: 42 Event occurrence: 1 Event detail code: 0  Application information:     Application domain: /LM/W3SVC/1/ROOT-1-128412128787656250     Trust level: Full     Application Virtual Path: /     Application Path: c:inetpubwwwroot     Machine name: DD-MAIN  Process information:     Process ID: 5544     Process name: w3wp.exe     Account name: NT AUTHORITYNETWORK SERVICE  Exception information:     Exception type: SqlException     Exception message: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.  Request information:     Request URL: http://localhost/Search_DG.aspx?SearchWord=1212     Request path: /Search_DG.aspx     User host address: 10.10.10.1     User:      Is authenticated: False     Authentication Type:      Thread account name: NT AUTHORITYNETWORK SERVICE  Thread information:     Thread ID: 1     Thread account name: NT AUTHORITYNETWORK SERVICE     Is impersonating: False     Stack trace:    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)   at System.Data.SqlClient.SqlDataReader.SetMetaData(_SqlMetaDataSet metaData, Boolean moreInfo)   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()   at System.Data.SqlClient.SqlDataReader.get_MetaData()   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)   at System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)   at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)   at System.Web.UI.WebControls.DataBoundControl.PerformSelect()   at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()   at System.Web.UI.WebControls.GridView.DataBind()   at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()   at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()   at System.Web.UI.Control.EnsureChildControls()   at System.Web.UI.WebControls.GridView.get_Rows()   at Install_DG.Page_Load(Object sender, EventArgs e)   at System.Web.UI.Control.OnLoad(EventArgs e)   at System.Web.UI.Control.LoadRecursive()   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  Custom event details:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

View 3 Replies View Related

Help!!! Gridview Binding

Mar 20, 2008

Hey guys, Am in need of help please, basically the program im working with at the moment is when you add a New Contract, it will grab the Contract Number you have entered, Post it over to another page, then using that number bind a Gridview. The SQL being "SELECT Contract_ID, Contract_Number, Start_Date, End_Date, Quarterly_Rent FROM ECS_Contracts_Test WHERE Contract_Number = " & conNoVar (this being the Contract Number of the recently added Contract), however then it comes to Bind the Grid it kicks up an System.Data.SqlClient.SqlException: Syntax error converting the nvarchar value
'2009P7899' to a column of data type int.But the Column Contract_Number is set to Varchar and all I really want to do is to create this gridview using this criteria and not convert anything! The Contract_ID is an int, which is needed as I increment it. Heres the error code:   Public Sub BindtheGrid()'Bind the Contract Grid, where ContractID is used
Dim SQL As String = "Contract_ID, Contract_Number, Start_Date, End_Date, Quarterly_Rent"
Dim objConn As SqlConnection = New SqlConnection(ConnectionString)
Dim cmdstock As SqlCommand = New SqlCommand("SELECT " & SQL & " FROM ECS_Contracts_Test WHERE Contract_Number = " & contractQueryID, objConn)
cmdstock.CommandType = CommandType.Text
objConn.Open()
GridView1.DataSource = cmdstock.ExecuteReader()
GridView1.DataBind()
objConn.Close()
End Sub If you need any more information then please let me know. Mucho Aprreciated   

View 1 Replies View Related

Gridview And Sqldatasource

May 3, 2008

 
i have a gridview which is bound to sqldatasource. i have a delete button in the gridview. I have written code for "deleting" a record in app_code directory.
now iam not using "deletecommand" of sqldatasource but on the click of "delete" link i want to call the procedure in the app_code.
Any ideas on how to do it.??
 

View 4 Replies View Related

Searching A Gridview In ASP.NET 2.0

Dec 15, 2005

Hello,How do I search through the gridview?  Would I do this at the sqldatasourcelevel?I figured that I sould search with the datatable.select but how do I accessthe datatable of the sqldatasource?I am using ASP.NET 2.0 with VB.Thanks for your helpJ

View 2 Replies View Related

GridView - SqlDataSource

Apr 14, 2006

I have created a GridView that uses a SqlDataSource.  When I run the page it does not pull back any data.  However when I test the query in the SqlDataSource dialog box it pulls back data.
Here is my GridView and SqlDataSource:
<asp:GridView ID="Results" runat="server" AllowPaging="True" AllowSorting="True"
CellPadding="2" EmptyDataText="No records found." AutoGenerateColumns="False" Width="100%" CssClass="tableResults" PageSize="20" DataSourceID="SqlResults" >
<Columns>
<asp:BoundField DataField="DaCode" HeaderText="Sub-Station" SortExpression="DaCode" >
<ItemStyle HorizontalAlign="Center" CssClass="tdResults" />
<HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" />
</asp:BoundField>
<asp:BoundField DataField="DpInfo" HeaderText="Delivery Point" SortExpression="DpInfo" >
<HeaderStyle HorizontalAlign="Left" CssClass="tdHeaderResults" />
<ItemStyle CssClass="tdResults" />
</asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="CuCode,OrderID" DataNavigateUrlFormatString="TCCustDetail.asp?CuCode={0}&amp;OrderID={1}"
DataTextField="OrderID" HeaderText="Order No" SortExpression="OrderID">
<ItemStyle CssClass="tdResults" HorizontalAlign="Center" />
<HeaderStyle CssClass="tdHeaderResults" HorizontalAlign="Center" />
</asp:HyperLinkField>
<asp:BoundField HeaderText="Order Date" SortExpression="OrderDate" DataField="OrderDate" >
<ItemStyle HorizontalAlign="Center" CssClass="tdResults" />
<HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" />
</asp:BoundField>
<asp:BoundField DataField="ReqDeliveryDate" HeaderText="Req Delivery Date" SortExpression="ReqDeliveryDate" >
<ItemStyle HorizontalAlign="Center" CssClass="tdResults" />
<HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" />
</asp:BoundField>
<asp:BoundField DataField="StatusDate" HeaderText="Status Date" SortExpression="StatusDate">
<ItemStyle HorizontalAlign="Center" CssClass="tdResults" />
<HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" />
</asp:BoundField>
<asp:BoundField DataField="ManifestNo" HeaderText="Manifest No" SortExpression="ManifestNo">
<ItemStyle HorizontalAlign="Center" CssClass="tdResults" />
<HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" />
</asp:BoundField>
<asp:BoundField DataField="CustomerPO" HeaderText="P.O. No" SortExpression="CustomerPO">
<ItemStyle HorizontalAlign="Center" CssClass="tdResults" />
<HeaderStyle HorizontalAlign="Center" CssClass="tdHeaderResults" />
</asp:BoundField>
<asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class">
<ItemStyle HorizontalAlign="Left" CssClass="tdResults" />
<HeaderStyle HorizontalAlign="Left" CssClass="tdHeaderResults" />
</asp:BoundField>
<asp:BoundField DataField="OrderStatus" HeaderText="Order Status" SortExpression="StatusSort">
<ItemStyle HorizontalAlign="Left" CssClass="tdResults" />
<HeaderStyle HorizontalAlign="Left" CssClass="tdHeaderResults" />
</asp:BoundField>
</Columns>
<HeaderStyle ForeColor="White" HorizontalAlign="Left" />
<AlternatingRowStyle CssClass="tdResultsAltRowColor" />
</asp:GridView>
<asp:SqlDataSource ID="SqlResults" runat="server" ConnectionString="<%$ ConnectionStrings:TransportationConnectionString %>" SelectCommand="GetOrderSummaryResults" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter DefaultValue="10681" Name="CuCode" Type="String" />
<asp:Parameter DefaultValue="" Name="DaCode" Type="String" />
<asp:Parameter DefaultValue="" Name="DpCode" Type="String" />
<asp:Parameter DefaultValue="" Name="OrderID" Type="String" />
<asp:Parameter DefaultValue="" Name="ManifestNo" Type="String" />
<asp:Parameter DefaultValue="" Name="PONo" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
I can get it to fill with data by manually filling the GridView without using a SqlDataSource but then I cannot get the sorting to work when I do it that way.  Actually not sure if the sorting will work this way either as I cannot get it to fill with data.  Any ideas would be much appreciated.

View 1 Replies View Related

Gridview Question

Jun 1, 2006

Sqldatasources are used for a dropdownlist and a gridview. How can the dropdownlist selection refresh the gridview? This is done programmatically in ASP.NET 1.1 code behind. Can it be done in ASP.NET 2.0 without code behind? Thanks.

View 2 Replies View Related

Specifying Updateparameters In Gridview

Jun 7, 2006

Where exactly are the updateparameters of a gridview picked up from?  I have created 2 very similar gridviews and given the updateparameters the same names as in my edititemtemplates.  Yet this method has worked for 1 gridview and failed for the second gridview.  Here is my gridview :
 <asp:SqlDataSource ID="SqlDataSource1" runat="server"                ConnectionString="<%$ ConnectionStrings:XConnectionString %>"               SelectCommand="ViewForecast" SelectCommandType="StoredProcedure"               DeleteCommand="DeleteForecast" DeleteCommandType="StoredProcedure"               UpdateCommand="UpdateForecast" UpdateCommandType="StoredProcedure">                   <DeleteParameters>                       <asp:Parameter Name="ForecastKey" Type="Int32" />                   </DeleteParameters>                   <UpdateParameters>                       <asp:Parameter Name="ForecastKey" Type="Int32" />                       <asp:Parameter Name="CompanyKey" Type="Int64" />                       <asp:Parameter Name="ForecastType" Type="Char" />                       <asp:Parameter Name="MoneyValue" Type="Double" />                       <asp:Parameter Name="ForecastPercentage" Type="Double" />                       <asp:Parameter Name="DueDate" Type="DateTime" />                       <asp:Parameter Name="UserKey" Type="Int32" />                   </UpdateParameters>               </asp:SqlDataSource>                               <asp:SqlDataSource ID="SqlDataSource2" runat="server"                                     ConnectionString="<%$ ConnectionStrings:XConnectionString %>"                                    SelectCommand="GetCompaniesByUser" SelectCommandType="StoredProcedure">                                     </asp:SqlDataSource>                                                                         <asp:SqlDataSource ID="SqlDataSource3" runat="server"                                     ConnectionString="<%$ ConnectionStrings:XConnectionString %>"                                    SelectCommand="GetForecastTypes" SelectCommandType="StoredProcedure">                                     </asp:SqlDataSource>                                                                          <asp:SqlDataSource ID="SqlDataSource4" runat="server"                                     ConnectionString="<%$ ConnectionStrings:XConnectionString %>"                                    SelectCommand="GetForecastPercentages" SelectCommandType="StoredProcedure">                                     </asp:SqlDataSource>                                                     <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"                SkinID="Grey" AutoGenerateColumns="false" DataKeyNames="ForecastKey" AllowSorting="true"                OnRowDataBound="GridView1_RowDataBound" EditRowStyle-CssClass="dgedit" OnRowUpdated="GridView1_RowUpdated" OnRowEditing="GridView1_RowEditing"                OnRowDeleting="GridView1_RowDeleting">                   <Columns>                       <asp:TemplateField HeaderText="Key" SortExpression="ForecastKey">                                            <ItemTemplate>                                                <asp:Label ID="lblForecastKey" Text='<%# Bind("ForecastKey") %>' runat="server"></asp:Label>                                            </ItemTemplate>                                            <ItemStyle Height="24px" Width="50px" />                                            </asp:TemplateField>                                          <asp:TemplateField HeaderText="Company" SortExpression="CompanyName">                                            <ItemTemplate>                                                <asp:Label ID="lblCompany" Text='<%# Eval("CompanyName") %>' runat="server"></asp:Label>                                            </ItemTemplate>                                            <EditItemTemplate>                                                <asp:DropDownList ID="ddlCompanyName" DataSourceID="SqlDataSource2" Runat="Server"                                                 DataTextField="CompanyName" DataValueField="CompanyKey" SelectedValue='<%# Bind("CompanyKey") %>' />                                            </EditItemTemplate>                                            <ItemStyle Height="24px" Width="50px" />                                            </asp:TemplateField>                                                                                        <asp:TemplateField HeaderText="Forecast Type" SortExpression="ForecastDescription">                                            <ItemTemplate>                                                <asp:Label ID="lblForecastType" Text='<%# Eval("ForecastDescription") %>' runat="server"></asp:Label>                                            </ItemTemplate>                                            <EditItemTemplate>                                                <asp:DropDownList ID="ddlForecastType" DataSourceID="SqlDataSource3" Runat="Server"                                                 DataTextField="ForecastDescription" DataValueField="ForecastType" SelectedValue='<%# Bind("ForecastType") %>' />                                            </EditItemTemplate>                                            <ItemStyle Height="24px" Width="50px" />                                            </asp:TemplateField>                                                                                        <asp:TemplateField HeaderText="Value (£)" SortExpression="MoneyValue">                                            <ItemTemplate>                                                <asp:Label ID="lblMoneyValue" Text='<%# Eval("MoneyValue", "{0:#,###.00}") %>' runat="server"></asp:Label>                                            </ItemTemplate>                                            <EditItemTemplate>                                                <asp:TextBox ID="txtMoneyValue" Text='<%# Bind("MoneyValue", "{0:#,###.00}") %>' runat="server"></asp:TextBox>                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"                                                ControlToValidate="txtMoneyValue" Display="None" ErrorMessage="Please enter a Value" />                                                <asp:CompareValidator ID="CompareValidator1" runat="server" Display="None"                                                ErrorMessage="Value must be numeric" ControlToValidate="txtMoneyValue"                                                Type="Double" Operator="DataTypeCheck"></asp:CompareValidator>                                            </EditItemTemplate>                                            <ItemStyle Height="24px" Width="50px" />                                            </asp:TemplateField>                                                                                        <asp:TemplateField HeaderText="Probability (%)" SortExpression="ProbabilityValue">                                            <ItemTemplate>                                                <asp:Label ID="lblProbability" Text='<%# Eval("ForecastPercentage") %>' runat="server"></asp:Label>                                            </ItemTemplate>                                            <EditItemTemplate>                                                <asp:DropDownList ID="ddlForecastPercentage" DataSourceID="SqlDataSource4" Runat="Server"                                                 DataTextField="ForecastPercentageDescription" DataValueField="ForecastPercentage" SelectedValue='<%# Bind("ForecastPercentage") %>' />                                            </EditItemTemplate>                                            <ItemStyle Height="24px" Width="50px" />                                            </asp:TemplateField>                                                                                        <asp:TemplateField HeaderText="Value (£) x Probability (%)" SortExpression="ProbabilityValue">                                            <ItemTemplate>                                                <asp:Label ID="lblProbabilityValue" Text='<%# Eval("ProbabilityValue", "{0:#,###.00}") %>' runat="server"></asp:Label>                                            </ItemTemplate>                                            <ItemStyle Height="24px" Width="50px" />                                            </asp:TemplateField>                                                                                        <asp:TemplateField HeaderText="Due Date" SortExpression="DueDate">                                            <ItemTemplate>                                                <asp:Label ID="lblDueDate" Text='<%# Eval("DueDate", "{0:dd/MM/yyyy}") %>' runat="server"></asp:Label>                                            </ItemTemplate>                                            <EditItemTemplate>                                               <asp:TextBox ID="txtDueDate" Text='<%# Bind("DueDate", "{0:dd/MM/yyyy}") %>' runat="server"></asp:TextBox>                                               <!--or use this in SQL : Select Convert(VarChar(10), GetDate(), 103)-->                                               <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"                                                ControlToValidate="txtDueDate" Display="None" ErrorMessage="Please enter a Due Date" />                                                <asp:CompareValidator ID="CompareValidator2" runat="server"                                               Display="None" ErrorMessage="Please enter a valid Due Date in format dd/mm/yyyy"                                               ControlToValidate="txtDueDate" Type="Date" Operator="DataTypeCheck"></asp:CompareValidator>                                            </EditItemTemplate>                                            <ItemStyle Height="24px" Width="65px" />                                            </asp:TemplateField>                                                                                        <asp:TemplateField HeaderText="Last Edit Date" SortExpression="LastEditDate">                                            <ItemTemplate>                                                <asp:Label ID="lblLastEditDate" Text='<%# Eval("LastEditDate", "{0:dd/MM/yyyy}") %>' runat="server"></asp:Label>                                            </ItemTemplate>                                            <ItemStyle Height="24px" Width="50px" />                                            </asp:TemplateField>                                                                                        <asp:CommandField ShowEditButton="True" ButtonType="Link" ShowCancelButton="True"                                            UpdateText="Update" EditText="Edit" CancelText="Cancel" />                                                                                        <asp:TemplateField>                                             <ItemTemplate>                                               <asp:LinkButton ID="DeleteButton"                                                  CommandArgument='<%# Eval("ForecastKey") %>'                                                  CommandName="Delete" runat="server">                                                 Delete</asp:LinkButton>                                             </ItemTemplate>                                           </asp:TemplateField>                                         </Columns>                </asp:GridView>
And here is my stored proc :
CREATE procedure dbo.UpdateForecast
( @ForecastKey int, @CompanyKey bigint, @ForecastType char(1), @MoneyValue float, @ForecastPercentage float, @DueDate datetime, @UserKey int)
as
update Forecastset CompanySiteKey = @CompanyKey,MoneyValue = @MoneyValue,Probability = @ForecastPercentage,ForecastType = @ForecastType,InvoiceDate = @DueDate,UserKey = @UserKeywhere ForecastKey = @ForecastKeyGO
Can anybody with more experience of using gridview please tell me where I am going wrong?
Cheers,
Mike

View 1 Replies View Related

Editing In The GridView

Nov 16, 2007

Hi

I want to Enable Editing in the GridView
but there is a problem

the GridView take its data from 2 tables and I do this by the
build query

so I can't choose the " advance " button and check for enable update and delete statements

and when I try to build the update query in the update tap
I don't know what to write in the "new value" column

so how can enable editing in the GridView that take from
2 tables???????

please help me
and thanks

View 3 Replies View Related

Crosstable In Gridview

Feb 29, 2008

First of all I like to say hello. Its my first post and I hope somebody will be so kind and help me.
I have 3 tables in a database. They look like follow:

1. Table called State:
------------------------------
Id
Caption

2. Table called Craft:
-----------------------------
Id
Caption

3. Table called Wage:
-------------------------------
StateId
CraftId
Wage (decimal)

What I'm trying to do is, create a crosstable like the following and display it in a Gridview

Texas California Washington ...
digging 25,60 31,42 ...

masonry works 40.66 ... ...


So, the columns come from table State, the row titles come from Craft and the values from Wage. After changing the values I want to save values back to Wage.

I started to build this crosstable but faced several problems. For example I dont know how to set a Caption on the left side of each row (Caption of table Craft).
And even worse, how shall I update table Wage if there are no Id's in the crosstable anymore to make sure that I save the Value on the right place back in table Wage.

It would be very kind if somebody has a solution or a method of resolution.

View 1 Replies View Related

Retrieve Data From The Gridview

Jun 19, 2006

i need to retrieve data from a particular field of the gridview according to the selected row to stored it into session .....what i had done so far as following: Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)        DetailsView1.PageIndex = GridView1.SelectedIndex        Session.Add("receiverName", GridView1.??????)            End Sub????? is the part i am not sure what to code.... i tried different method by seems to have problem of convertion.

View 1 Replies View Related

Default Data Value In Gridview?

Jun 28, 2006

Hi, I am trying to set a default value for a date field in my update parameters:When I try an update with the DefaultValue="<% Now %>", I get this error:"String was not recognized as a valid DateTime."The updates work fine if no default value is set and it also works ok if I change the default value to a set string, such as "6/24/06".  I've tried using different data sources and datasets, but no luck.Anyone have any ideas on this?Thanks! <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db1ConnectionString %>"
ProviderName="<%$ ConnectionStrings:db1ConnectionString.ProviderName %>" SelectCommand="SELECT [ID], [Name], [Date] FROM [Table1]" DeleteCommand="DELETE FROM [Table1] WHERE [ID] = ?" InsertCommand="INSERT INTO [Table1] ([ID], [Name], [Date]) VALUES (?, ?, ?)" UpdateCommand="UPDATE [Table1] SET [Name] = ?, [Date] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Date" Type="DateTime" DefaultValue="<% Now() %>" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Date" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Date" HeaderText="Date" ReadOnly="true" SortExpression="Date" />
</Columns>
</asp:GridView> 

View 3 Replies View Related

Gridview Refresh After Update

Aug 14, 2006

Hi All,
I am new to development of asp. I have an SQLDataSource set as the data source for a grid view.  When I click on the edit link in the Gridview, change the data, and click update, the old data  is still displayed in the row.
I found exact same issue as here -- http://forums.asp.net/thread/1217014.aspx
Solution in the above thread is to add this
            {                if (reader != null) reader.Close();            }            conn.Close();
How do I apply above solution in my situation ?
 
I am updating through stored procedure.and don't have code at background.  My code is
Datasource :
<asp:SqlDataSource
ID="ds"
runat="server"
ConnectionString="<%$ ConnectionStrings:ds %>"

CancelSelectOnNullParameter="False"
ProviderName="<%$ ConnectionStrings:ds.ProviderName%>"
UpdateCommand="usp_save"
UpdateCommandType="StoredProcedure"
EnableCaching="False">
 
<UpdateParameters>
<asp:Parameter Name="field1" Type="String" />
<asp:Parameter Name="field2" Type="String" />
<asp:Parameter Name="field3" Type="String" />
<asp:Parameter Name="field4" Type="String"/>
<asp:ControlParameter Name="field5" Type="String" ControlID = "label7" />
</UpdateParameters>
 

View 8 Replies View Related

More Problems With Gridview And SQL Procedures

Sep 11, 2006

I have successfully used SQL procedures to provide data to a Gridview previously, and I just can't see what's different about the simplified case that works and the real case that doesn't.  I've extracted the code into a test page to avoid extraneous bumph. 1.     I have developed a SQL procedure, GDB_P_Children, and tested this in SQL Server Management Studio Express.  It returned exactly what it should.  The procedure is: -SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[GDB_P_Children]@IndiiD uniqueidentifier, @Option int,@Owner Varchar(50),@User Varchar(50)AS       Select * from GDBChildren(@Indiid, @Option, @Owner, @User)GO2.    I then tried to use it in my program to power a Gridview, but the gridview was blank.   I put the Gridview into a test page that only had code: -Option Compare TextPartial Class test    Inherits System.Web.UI.Page    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        Session("INDIid") = "ffe1fb2f-88ce-4b64-a358-e21efd161d70"        Label2.Text = Session("INDIid")    '   These are just for debugging        Session("Owner") = "robertb"        Label3.Text = Session("Owner") & ","        Session("Option") = 0        Label4.Text = Session("Option") & ","        Session("gdvChildUser") = ""        Label5.Text = Session("gdvChildUser") & ","    End SubEnd ClassI then regenerated the gridview from scratch: -  Toolbox: drag a gridview on to the page  Click "Configure Data sourec" => New Data Source => SQL Database.   Name the datasource SQLChildren.        Connection string - select as normal        Configure:  Specify a custom SQL statement or procedure        Select Stored Procedure, select GDB_P_Children                Set parameters to: -                       INDIid        Session("INDIid")                       Option       Session("Option")                       Owner       Session("Owner")                       User          Session("gdbChildUser")Test Query showed that the first parameter, INDIid, had type Object, and I know that this will fail (see http://forums.asp.net/thread/1390374.aspx), so I finished data source configuration and edit the source of the test page to remove  Type="Object" from the parameter definition.   The parameter now has type "Empty", and filling it in with the values ffe1fb2f-88ce-4b64-a358-e21efd161d70, 0, robertb, and '' returns data as expected.  Click Finish and the Gridview configures itself with the correct column headings: -Exactly correct so far.  Yet executing the page shows only my debugging labels, with no sign of the gridview.I changed the stored procedure: -set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGO --          Temporary testing version, stripped to bare essentialsALTER PROCEDURE [dbo].[GDB_P_Children]      @IndiiD uniqueidentifier AS      Select INDIid, Indiusername, dbo.gdbindinamedate(INDIid) as IndiNameDate, Indisex            from nzgdb_Indi where INDIMothersindiid = @INDIidData configuration was redone, then the page was displayed.  It now correclty shows data from the database.  So what's different?I changed the procedure back to the original,  and again the blank (except for debugging labels) page was displayed.The data configuration was changed so that only the first parameter, @INDIid, was passed, and the other were set to default values.   Still the blank page.Procedure GDB_P_Children was then changed to have only one parameter, with the other three declared and given values internally: -ALTER PROCEDURE [dbo].[GDB_P_Children]      @IndiiD uniqueidentifierAS      Declare @Option int      Declare @Owner Varchar(50)      Declare @User     Varchar(50)      Set @Option = 0      Set @Owner = 'robertb'      set @User =''Select * from GDBChildren(@Indiid, @Option, @Owner, @User)GOSET ANSI_NULLS OFFGOSET QUOTED_IDENTIFIER OFFGO   The page is now OK, with the gridview showing data as expected.So why can't I use this procedure with the four arguments that it is supposed to have?   This is driving me crazy!   I have other procedures with 2 arguments (both Uniqueidentifier) that work fine, so it's not the fact that this procedure has more than one argument that's causing problems.  Help!!!!Regards, Robert Barnes

View 12 Replies View Related

Refreshing Data In GridView

Sep 18, 2006

Hi,I’m new to SQL Express, but I have created a table and a stored proc to populate it.I have dragged the table into a form so I can view the data in a GridView.I have added a button to add new rows to the table. All the above works fine, except when I hit add, the data gets added, but the GridView doesn’t update and show the new data.  Is there some code I can add to the add button that also refreshed the GridView? ThanksMike

View 2 Replies View Related

UPDATE Not Working In Gridview

Sep 26, 2006

I am trying to update a field in gridview. My update is not working, sort of. The original value is being updated with a NULL value when I click on the update button.here is my code <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" AutoGenerateEditButton="True" DataKeyNames="rqt_id">UpdateCommand="UPDATE [rqt_data] SET [rqt_title]=@rqt_title WHERE [rqt_id] = @rqt_id" >      <asp:Parameter Name="rqt_title" Type="String" /> the field rqt_title is set up as a NVarChar(25) in the db. I can't specify that for the Type property. Could that be the issue?thx

View 4 Replies View Related







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