Imports
System.Data.SqlClientImports
System.TextNamespace
RMCWebSite Public Class handbook Inherits System.Web.UI.Page Protected WithEvents txtID As System.Web.UI.WebControls.TextBox Protected WithEvents txtSchoolYear System.Web.UI.WebControls.TextBox Protected WithEvents txtTeamName As System.Web.UI.WebControls.TextBoxProtected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button3 As System.Web.UI.WebControls.Button Protected WithEvents Button4 As System.Web.UI.WebControls.Button Protected WithEvents Button5 As System.Web.UI.WebControls.Button Dim mySqlDataAdapter As SqlDataAdapter Dim myDataSet As Data.DataSet = New Data.DataSet() Dim myDataTable As Data.DataTable = New Data.DataTable() Dim myConnection As SqlConnection Dim myCommand As SqlCommandBuilder Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadmyConnection =
New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("rmcws")) TrymySqlDataAdapter =
New SqlDataAdapter("SELECT * FROM SportsTeams", myConnection) CatchConsole.WriteLine(
"Error Opening {0}", myConnection.DataSource) End TrymyCommand =
New SqlCommandBuilder(mySqlDataAdapter) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'submit buttonmyConnection.Open()
mySqlDataAdapter.Fill(myDataSet,
"SportsTeams")myConnection.Close()
myDataTable = myDataSet.Tables(
"SportsTeams") Dim rowSportsTeams As Data.DataRow = myDataTable.NewRow()rowSportsTeams(
"ID") = txtID.TextrowSportsTeams(
"SchoolYear") = txtSchoolYear.TextrowSportsTeams(
"TeamName") = txtTeamName.TextmyDataTable.Rows.Add(rowSportsTeams)
mySqlDataAdapter.Update(myDataSet,
"SportsTeams")myDataSet.Tables(
"SportsTeams").AcceptChanges()Refresh()
End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'add new buttonClearScreen()
myConnection.Open()
mySqlDataAdapter.Fill(myDataSet,
"SportsTeams")myConnection.Close()
myDataTable = myDataSet.Tables(
"SportsTeams") Dim rowSportsTeams As Data.DataRow = myDataTable.NewRow()rowSportsTeams(
"ID") = txtID.TextrowSportsTeams(
"SchoolYear") = txtSchoolYear.TextrowSportsTeams(
"TeamName") = txtTeamName.Text Dim newDataSet As Data.DataSetnewDataSet = myDataSet.GetChanges()
mySqlDataAdapter.Update(newDataSet,
"SportsTeams")myDataSet.Tables(
"SportsTeams").AcceptChanges()Refresh()
End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click 'delete buttonmyConnection.Open()
mySqlDataAdapter.Fill(myDataSet,
"SportsTeams")myConnection.Close()
myDataTable = myDataSet.Tables(
"SportsTeams")myDataTable.Rows(0).Delete()
mySqlDataAdapter.Update(myDataSet,
"SportsTeams")myDataSet.Tables(
"SportsTeams").AcceptChanges()Refresh()
End Sub Private Sub button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.click 'refreshRefreshL()
End Sub Private Sub ClearScreen()txtID.Text =
""txtSchoolYear.Text =
""txtTeamName.Text =
"" End Sub Private Sub Refresh()myDataSet =
New Data.DataSet()myDataTable =
New Data.DataTable()myConnection.Open()
mySqlDataAdapter.Fill(myDataSet,
"SportsTeams")myConnection.Close()
myDataTable = myDataSet.Tables(
"SportsTeams") Dim rowSportsTeams As Data.DataRow = myDataTable.Rows(5)txtID.Text = rowSportsTeams(
"ID")txtSchoolYear.Text = rowSportsTeams(
"SchoolYear")txtTeamName.Text = rowSportsTeams(
"TeamName") End Sub End ClassEnd
Namespace
sladjanaPosted Oct 19, 2007, 10:16 AM
ok.i got it - it's working!! :)
i put it into the original surrounding (onto a test-site) and inserted a tiny little line of code - codefile="....aspx.vb"
silly me!!! :)
thanx for all the views!!
appreciate it!
bless you all.
s.
sladjanaPosted Oct 17, 2007, 9:13 AM
hi Jan,
thank you for writting.
i don't know.i am adding a new page(s)/section to already existing web app and..i haven't commited the page onto the live site yet because of all the testings..so i just go preview in browser to see what's going on and the thing is - nothing happens!!and errors i get in run-time are just some "official" stuff,guess because i don't run it as a part of it's belonging web app..
i want to browse and add data into a database table but nothing seams to be happening..and i'm kinda new in asp.net so i don't know what's going on..i've tried a lot of stuff and this code (by "the rules") should be working,but is not.
i was wondering maybe some of you guys could see the missing stuff better from your perspective..
any comment appreciated.
thanx!!
sladjana
Jan MontanoPosted Oct 16, 2007, 9:17 PM
What exactly is the problem you're encountering with the code? Do you encounter compile-time error messages? What kind of error messages?
Regards,
Jan