主题:为什么说没有定义????????
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=Student;user id=sa;password=0")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = "SELECT 学号,姓名,性别 FROM 学生信息 JOIN 专业信息 ON 学生信息.专业名=专业信息.专业名"
objDataAdapter.SelectCommand.CommandType = CommandType.Text
objConnection.Open()
objDataAdapter.Fill(objDataSet, "Student")
objConnection.Close()
StuPro.DataSource = objDataSet
StuPro.DataMember = "学生信息"
objDataAdapter = Nothing
objConnection = Nothing
End Sub
End Class
在编译的时候提示说:"SqlConnection is not defined."
为什么说没有定义.不是有声明了吗?请指教...
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=Student;user id=sa;password=0")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = "SELECT 学号,姓名,性别 FROM 学生信息 JOIN 专业信息 ON 学生信息.专业名=专业信息.专业名"
objDataAdapter.SelectCommand.CommandType = CommandType.Text
objConnection.Open()
objDataAdapter.Fill(objDataSet, "Student")
objConnection.Close()
StuPro.DataSource = objDataSet
StuPro.DataMember = "学生信息"
objDataAdapter = Nothing
objConnection = Nothing
End Sub
End Class
在编译的时候提示说:"SqlConnection is not defined."
为什么说没有定义.不是有声明了吗?请指教...