信息系统与数据库的实践课作业,做一个售书管理系统,分店员和顾客的,数据库用的SQL service 2005,前端用的Visual Studio 2008。
  我做的先一个登录界面,然后输入不同帐号进入不同界面,可无论店员的还是顾客的都闪退没有任何报错,代码也没有红色波浪线,好几天了都没弄好,周四就要交报告了,请大神指点。
PS:我不是学计算机的,没学过VB,数据库就刚上这一学期,请大神解释的通俗点……
下面粘代码了,这是店员的:
Imports System.Data.SqlClient
 Public Class Form3
     Inherits System.Windows.Forms.Form
     Public mybind As BindingManagerBase
     Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         SqlDataAdapter1.Fill(DataSet11.book)
         mybind = BindingContext(DataSet11, "book")
         DataGrid1.DataSource = DataSet11.book
         DataGrid2.DataSource = DataSet11.book
         GroupBox2.Visible = False
         GroupBox1.Visible = True
         GroupBox3.Visible = False
     End Sub
     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
         GroupBox2.Visible = False
         GroupBox1.Visible = True
         GroupBox3.Visible = False
     End Sub
     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
         GroupBox1.Visible = False
         GroupBox2.Visible = True
         GroupBox3.Visible = False
     End Sub
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
         End
     End Sub
     Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
         mybind.AddNew()
     End Sub
     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
         mybind.RemoveAt(mybind.Position)
     End Sub
     Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
         mybind.EndCurrentEdit()
         SqlDataAdapter1.Update(DataSet11.book)
     End Sub
     Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
         mybind.Position = DataGrid1.CurrentRowIndex
     End Sub
     Private Sub DataGrid2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid2.Click
         mybind.Position = DataGrid2.CurrentRowIndex
     End Sub
     Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
         mybind.EndCurrentEdit()
         SqlDataAdapter1.Update(DataSet11.book)
     End Sub
     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
         GroupBox1.Visible = False
         GroupBox2.Visible = False
         GroupBox3.Visible = True
     End Sub
 End Class
界面是这样的这个是顾客的
Imports System.Data.SqlClient
 Public Class Form4
     Inherits System.Windows.Forms.Form
     Public mybind As BindingManagerBase
     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
         End
     End Sub
     Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
         TextBox1.Text = ""
     End Sub
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
         GroupBox2.Visible = False
         GroupBox3.Visible = False
         GroupBox1.Visible = True
     End Sub
     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
         GroupBox1.Visible = False
         GroupBox3.Visible = False
         GroupBox2.Visible = True
     End Sub
     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
         GroupBox1.Visible = False
         GroupBox2.Visible = False
         GroupBox3.Visible = True
     End Sub
     Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
         Dim sql As String = "select bookname as 书名,price as 价格, publisher as 出版社 from book where bookname ='" & TextBox1.Text & "'"
         Dim myconn As New SqlConnection("initial catalog = book;data source=(local);integrated security=sspi;")
         Dim myadaper As SqlDataAdapter = New SqlDataAdapter(sql, myconn)
         Dim mydataset As New DataSet
         myadaper.Fill(mydataset, "book")
         DataGrid1.DataSource = mydataset.Tables("book")
     End Sub
     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
         mybind.EndCurrentEdit()
         SqlDataAdapter1.Update(DataSet11.customer)
     End Sub
     Private Sub Form4_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         SqlDataAdapter2.Fill(DataSet11.customer)
         mybind = BindingContext(DataSet11, "Customer")
         SqlDataAdapter1.Fill(DataSet11.BookOrder)
         mybind = BindingContext(DataSet11, "BookOrder")
         DataGrid1.DataSource = DataSet11.BookOrder
         Dim myconn As New SqlConnection("Initial Catalog = Bookxp; Data Source=(Local);Integrated Security=SSPI;")
         Dim sql As String = "Select CustomerCode,Name,Sex,Job,Birthday,Hometown,Email,Telephone," _
                             & "VIPClass From Customer Where Customer.CustomerCode='01010101'"
         Dim mycmd As New SqlCommand(sql, myconn)
         Dim myread As SqlDataReader
         myconn.Open()
         myread = mycmd.ExecuteReader
         myread.Read()
         TextBox10.Text = myread.Item(0)
         TextBox2.Text = myread.Item(1)
         TextBox3.Text = myread.Item(2)
         TextBox4.Text = myread.Item(3)
         TextBox5.Text = myread.Item(4)
         TextBox6.Text = myread.Item(5)
         TextBox7.Text = myread.Item(6)
         TextBox8.Text = myread.Item(7)
         TextBox9.Text = myread.Item(8)
         myread.Close()
         myconn.Close()
         GroupBox2.Visible = False
         GroupBox3.Visible = False
         GroupBox1.Visible = True
     End Sub
 End Class
界面是这样的

解决方案 »

  1.   

    不知道什么是闪退你把你的断点设置在执行代码的第一行,然后手动debug不就知道了
      

  2.   

    其实就是自动结束调试了
    你这么一说我终于想起如何从中间开始调试的方法了,只不过明天端午节机房不开门,自己电脑软件又没装……
    不过我一直觉得是form load 里的问题,尤其这里
             SqlDataAdapter1.Fill(DataSet11.book)
             mybind = BindingContext(DataSet11, "book")
             DataGrid1.DataSource = DataSet11.book
             DataGrid2.DataSource = DataSet11.book
    没觉得哪里有错……
            
      

  3.   

    你的Dataset11连接好了没有啊
      

  4.   

    先在查询分析器里面手动执行SQL语句无误再说。