数据库列很多,我没全写,所以用了....全部列
以下是引用smy727在2013-3-22 18:01:35的发言:
我的存储过程名称是什么?
哦哟,这个这个。。。。。
我的存储过程名称是什么?

程序代码:Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Conn As New SqlConnection("server=(local);database=你的数据库名称;uid=sa;pwd=你登录SQLSERVER的密码")
Dim sqlCommand As SqlCommand = New SqlCommand("这是你的存储过程的名称", Conn)
= CommandType.StoredProcedure '使用存储过程,而非SQL查询语句
Try
Conn.Open()
With sqlCommand.Parameters '为存储过程中的参数赋值
.Add("@UserName", SqlDbType.NVarChar, 50).Value = TextBox1.Text
.Add("@PhoneNumber", SqlDbType.Int, 4).Value = TextBox2.Text
.Add("@BornDate", SqlDbType.SmallDateTime, 4).Value = TextBox3.Text
End With
sqlCommand.ExecuteNonQuery()
MsgBox("当前数据已成功添加到数据库中。")
Catch ex As Exception
MsgBox(ex.Message)
Finally
sqlCommand.Dispose()
Conn.Dispose()
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'先在窗体上任意拖三个文本框
TextBox1.Text = "BCCN"
TextBox2.Text = "123456789"
TextBox3.Text = "2013-3-25"
End Sub
End Class