Please visit the following URL...it contains a lot of working examples along with complete source code.
http://samples.gotdotnet.com/quickstart/aspplus/doc/webdataaccess.aspx --- sas0riza <[EMAIL PROTECTED]> wrote: > Can someone point out what I did wrong? I'm using a > search form to > bring up the record to be edited. Yet once I edit > the record, the > next time I go search for it, it doesn't display it > and shows it as a > nonexisting record in the datagrid. In addition, > once I edit the > record, I should see the updated changes right in > the datagrid, but I > don't. The record disappears. Here's my code: > > ================================================================== > <%@ Page Language="VB" %> > <script runat="server"> > > Sub dgCoordinator_Edit(sender as Object, e as > DataGridCommandEventArgs) > dgCoordinator.EditItemIndex = > e.Item.ItemIndex > > dgCoordinator.DataSource = > GetCoordinator(lastname.Text, > firstname.Text) > dgCoordinator.DataBind() > End Sub > > > Sub dgCoordinator_Update(sender as Object, e > as > DataGridCommandEventArgs) > 'update database here > 'determind the value of the customer id > column > Dim userID as Integer = > e.Item.Cells(1).Text > > 'reference each textbox > Dim lname as TextBox = > e.Item.Cells(2).Controls(0) > Dim fname as TextBox = > e.Item.Cells(3).Controls(0) > Dim email as TextBox = > e.Item.Cells(4).Controls(0) > Dim phone as TextBox = > e.Item.Cells(5).Controls(0) > Dim regcode as TextBox = > e.Item.Cells(6).Controls(0) > Dim uname as TextBox = > e.Item.Cells(7).Controls(0) > Dim pword as TextBox = > e.Item.Cells(8).Controls(0) > Dim systemsecuid as TextBox = > e.Item.Cells(9).Controls(0) > Dim regsecuid as TextBox = > e.Item.Cells(10).Controls(0) > > UpdateCoordinator(userID, lname.Text, > fname.Text, > email.Text, phone.Text, regcode.Text, uname.Text, > pword.Text, > systemsecuid.Text, regsecuid.Text) > > > dgCoordinator.EditItemIndex = -1 > > dgCoordinator.DataSource = > GetCoordinator(lastname.Text, > firstname.Text) > dgCoordinator.DataBind() > End Sub > > Sub dgCoordinator_Cancel(sender as Object, e > as > DataGridCommandEventArgs) > dgCoordinator.EditItemIndex = -1 > > dgCoordinator.DataSource = > GetCoordinator(lastname.text, > firstname.Text) > dgCoordinator.DataBind() > End Sub > > > > > Function UpdateCoordinator(ByVal userUID As > Integer, ByVal > username As String, ByVal password As String, ByVal > lastName As > String, ByVal firstName As String, ByVal email As > String, ByVal phone > As String, ByVal [region] As String, ByVal > systemSecUID As Byte, > ByVal regSecUID As Byte) As Integer > Dim connectionString As String = > "server='localhost'; > user id='sa'; password='pooh2'; > Database='OTSODITMCallingCard"& _ > "db'" > Dim sqlConnection As > System.Data.SqlClient.SqlConnection > = New > System.Data.SqlClient.SqlConnection(connectionString) > > Dim queryString As String = "UPDATE > [Coordinator] SET > [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED], "& _ > "[EMAIL PROTECTED], [EMAIL PROTECTED], > [LastName] > [EMAIL PROTECTED], [EMAIL PROTECTED]"& _ > "ne, [EMAIL PROTECTED], > [EMAIL PROTECTED] WHERE > ([Coordinator].[U"& _ > "serUID] = @UserUID)" > Dim sqlCommand As > System.Data.SqlClient.SqlCommand = New > System.Data.SqlClient.SqlCommand(queryString, > sqlConnection) > > sqlCommand.Parameters.Add("@UserUID", > System.Data.SqlDbType.Int).Value = userUID > sqlCommand.Parameters.Add("@Username", > System.Data.SqlDbType.VarChar).Value = username > sqlCommand.Parameters.Add("@Password", > System.Data.SqlDbType.VarChar).Value = password > sqlCommand.Parameters.Add("@LastName", > System.Data.SqlDbType.Char).Value = lastName > sqlCommand.Parameters.Add("@FirstName", > System.Data.SqlDbType.Char).Value = firstName > sqlCommand.Parameters.Add("@Email", > System.Data.SqlDbType.VarChar).Value = email > sqlCommand.Parameters.Add("@Phone", > System.Data.SqlDbType.Char).Value = phone > sqlCommand.Parameters.Add("@Region", > System.Data.SqlDbType.Char).Value = [region] > > sqlCommand.Parameters.Add("@SystemSecUID", > System.Data.SqlDbType.TinyInt).Value = systemSecUID > sqlCommand.Parameters.Add("@RegSecUID", > System.Data.SqlDbType.TinyInt).Value = regSecUID > > Dim rowsAffected As Integer = 0 > sqlConnection.Open > Try > rowsAffected = > sqlCommand.ExecuteNonQuery > Finally > sqlConnection.Close > End Try > > Return rowsAffected > End Function > > > Function GetCoordinator(ByVal lastName As > String, ByVal > firstName As String) As > System.Data.SqlClient.SqlDataReader > Dim connectionString As String = > "server='localhost'; > user id='sa'; password='pooh2'; > Database='OTSODITMCallingCard"& _ > "db'" > Dim sqlConnection As > System.Data.SqlClient.SqlConnection > = New > System.Data.SqlClient.SqlConnection(connectionString) > > Dim queryString As String = "SELECT > [Coordinator].* FROM > [Coordinator] WHERE (([Coordinator].[LastName] = > @Las"& _ > "tName) AND ([Coordinator].[FirstName] = > @FirstName))" > Dim sqlCommand As > System.Data.SqlClient.SqlCommand = New > System.Data.SqlClient.SqlCommand(queryString, > sqlConnection) > > sqlCommand.Parameters.Add("@LastName", > System.Data.SqlDbType.Char).Value = lastName > sqlCommand.Parameters.Add("@FirstName", > System.Data.SqlDbType.Char).Value = firstName > > sqlConnection.Open > Dim dataReader As > System.Data.SqlClient.SqlDataReader = > sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection) > > Return dataReader > End Function > > > > 'Sub Page_Load(sender as Object, e as > EventArgs) > > 'If Not Page.IsPostBack then > 'dgCustomers.DataSource = > GetCustomers() > === message truncated === __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
