Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compilation Error

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I love learning new things and not understanding them. :( I have a script and don't understand why it isn't working. The word Source works with the others? Like I said I am a newbee

<%@ import Namespace=&quot;System.Data.sqlClient&quot; %>
<%@ import Namespace=&quot;System.Data&quot; %>
<%@ Page Language=&quot;vb&quot; Debug=&quot;true&quot; %>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<title>Lets give it a try</title>
<script runat=&quot;server&quot;>
Public Sub Page_Load(Source as Object, E As EventArgs)
if Not Page.IsPostBack Then
BindData( &quot;Name&quot; )
End If
End Sub

Public Sub BindData( strSortField As String)
Dim myDataSet as New DataSet
Dim mySqlDataAdapter as SqlDataAdapter
mySqlDataAdapter = New SqlDataAdapter( _
&quot;SELECT * FROM Person order by &quot; & strSortField, _
&quot;server=AM1ST_FS1;database=HRINFO;uid=sa;&quot;)
mySqlDataAdapter.Fill(myDataSet, &quot;Person&quot;)
PersonInfo.DataSource = myDataSet.Tables(&quot;Person&quot;)
PersonInfo.DataBind()
End Sub

public DataGrid_Sort(Source As Object, E As DataGridSortCommandEventArgs)
BindData( E.SortExpression )
End Sub

Public Sub DataGrid_Edit(Source As Object, E As DataGridCommandEventArgs)
personInfo.EditItemIndex= E.Item.ItemIndex
BindData()
End Sub

Public Sub DataGrid_Cancel(Source As Object, E As DataGridCommandEventArgs)
personInfo.EditItemIndex = -1
BindData()
End Sub

Public Sub DataGrid_Update(Source As Object, E As DataGridCommandEventArgs)
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim txtName As Textbox = E.Item.Cells(2).Controls(0)
Dim txtAddress As Textbox = E.Item.Cells(3).Controls(0)
Dim strUpdateStmt As String
strUpdateStmt = &quot;UPDATE Person SET Name = '&quot; & txtName.Text & &quot;', Address = '&quot; & txtAddress.Text & &quot;' WHERE ID = &quot; & E.Item.Cells(1).Text
myConnection = New SqlConnection(&quot;server=AM1ST_FS1;database=HRINFO;uid=sa&quot;)
myCommand = new SqlCommand(strUpdateStmt, myConnection)
myConnection.open()
myCommand.ExecuteNonQuery()

personInfo.EditItemIndex = -1
BindData()
End Sub
</script>
</HEAD>
<body>
<form id=&quot;Form1&quot; method=&quot;post&quot; runat=&quot;server&quot;>
<h3>Editing Records in The DataGrid</h3>
<asp:DataGrid id=&quot;PersonInfo&quot; Runat=&quot;server&quot;
AlternatingItemStyle-BackColor=&quot;#A6F4FD&quot;
AutoGeneratecolumns=&quot;false&quot;
onEditCommand=&quot;DataGrid_Edit&quot;
onCancelCommand=&quot;DataGrid_Cancel&quot;
onUpdateCommand=&quot;DataGrid_Update&quot;
AllowSorting=&quot;true&quot;
onSortCommand=&quot;DataGrid_Sort&quot;>
<columns>
<asp:editcommandcolumn
ButtonType=&quot;LinkButton&quot;
CancelText=&quot;Cancel&quot;
editText=&quot;Edit&quot;
UpdateText=&quot;Update&quot; />
<asp:boundcolumn
DataField=&quot;ID&quot;
HeaderText=&quot;ID&quot;
ReadOnly=&quot;true&quot; />
<asp:boundcolumn
DataField=&quot;Name&quot;
HeaderText=&quot;Name&quot; />
<asp:boundcolumn
DataField=&quot;Address&quot;
HeaderText=&quot;Address&quot; />
</columns>
</asp:DataGrid>
</form>
</body>
</HTML>

and I am getting the following error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'Source' is not declared.

Source Error:



Line 24: End Sub
Line 25:
Line 26: public DataGrid_Sort(Source As Object, E As DataGridSortCommandEventArgs)
Line 27: BindData( E.SortExpression )
Line 28: End Sub


 
Nevermind. Just me not thinking Might help if I had Sub in there
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top