vb.net连上了数据库,但写不进insert into 数据,急求帮忙!

andywsy 2008-03-22 03:10:25
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dsn As String = ConfigurationSettings.AppSettings("DSN_student")
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString = dsn
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = conn
cmd.CommandText = "insert into Student_login (s_id,sl_name,sl_pwd,sl_phone,sl_date,sl_mailbox,sl_memo) values ('" + number.Text + "','" + realname.Text + "','" + password1.Text + "','" + phone.Text + "','" + DateTime.Now.Date + "','" + email.Text + "','" + memo.Text + "')"
Try
conn.Open()
cmd.ExecuteReader()
Panel1.Visible = False
Panel2.Visible = True
Catch
Label1.Text = "注册失败"
Finally
conn.Close()
End Try
''''''''''''''''''''''''''''''''''''''
'Dim stulab As String = DropDownList1.SelectedItem.Text
Dim zc As String = "1"
'cmd.CommandText = "update " + stulab + "_class ("
cmd.CommandText = "update stuclass set shif =" + zc + " where stu_id ='" + number.Text + "'"
Try
conn.Open()
cmd.ExecuteReader()
Label1.Text = ""
Catch ex As Exception
Label1.Text = "失败"
Finally
conn.Close()
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'重置各项textbox内容为空()
number.Text = ""
realname.Text = ""
' username.Text = ""
password1.Text = ""
password2.Text = ""
phone.Text = ""
email.Text = ""
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Dim bool1 As Boolean = False
' Dim dsn As String = ConfigurationSettings.AppSettings("DSN_student")
' Dim conn As New SqlClient.SqlConnection
' conn.ConnectionString = dsn
' Dim cmd As New SqlClient.SqlCommand
' cmd.Connection = conn
' If Not IsPostBack Then
' cmd.CommandText = "SELECT T_id FROM teacher_login"
' Try
' conn.Open()
' DropDownList1.DataSource = cmd.ExecuteReader
' DropDownList1.DataTextField = "T_id"
' DropDownList1.DataBind()
' bool1 = True
' Catch
' Label1.Text = "读取失败"
' Finally
' conn.Close()
' End Try
' End If
End Sub
End Class
...全文
103 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
firein 2008-03-22
  • 打赏
  • 举报
回复
就是就是
miaoyu04 2008-03-22
  • 打赏
  • 举报
回复
执行insert 是ExecuteNonQuery吧?

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧