数据库操作问题.急急急急.大家来帮忙
类文件:SysFun.vb 内容如下
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class SysFun
Dim Conn As SqlConnection
Dim Cmd As SqlCommand
Dim InsertStr As String
Public Sub New()
Conn = New SqlConnection( "Data Source=3090BBDE6C2F4EE\SQLEXPRESS;Initial Catalog=public;Integrated Security=True ")
End Sub
Public Sub InsertData()
Conn.Open()
InsertStr = "INSERT INTO DataApp (UID,Uname, Upassowrd, Udepartment, Uage,Usex) VALUES ( '1 ', '2 ', '3 ', '4 ', '5 ', '6 ') "
Cmd = New SqlCommand(InsertStr, Conn)
Cmd.ExecuteNonQuery()
Conn.Close()
End Sub
End Class
Default.aspx文件内容如下
Imports SysFun
Partial Class _Default
Inherits System.Web.UI.Page
Dim Opera As SysFun
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Opera.InsertData()
End Sub
End Class
提示出错 大家快来帮帮我 谢谢 给个例子也行.要vb的
本人qq:8685266 欢迎交流
------解决方案--------------------Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Opera = New SysFun() //VB.NET不熟,估计是这样,但肯定是你没实例化对对象
Opera.InsertData()
End Sub
------解决方案--------------------Dim Opera As SysFun
改为Dim Opera As New SysFun
------解决方案--------------------Dim Opera As SysFun
改为Dim Opera As New SysFun
==============================