当前位置:编程学习 > VB >>

求助!vb.net OleDbcommand 连接问题

 我是vb.net初学者,现在做个数据库系统,在编译时,向运行的窗体的输入框中输入字母或者汉字则出现   no value given for one or more required parameters     但是如果输入的是数字的话,则可以写入数据库!不知道什么原因。
各位牛人,帮个忙指导下[/color]不胜感激。
我的代码如下:

Dim strconn As String = " Provider = Microsoft.Jet.OLEDB.4.0;Data source=  C:\workshop \workshop.mdb"
        Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(strconn)
        Dim sqlstr As String = "INSERT INTO 项目信息 VALUES(" + CStr(TextBox2.Text) + "," + CStr(TextBox1.Text) + "," + CStr(DateTimePicker1.Text) + "," + CStr(TextBox5.Text) + "," + CStr(TextBox4.Text) + "," + CStr(TextBox21.Text) + ")"
        Dim comm As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlstr, conn)
        comm.Connection = conn
        conn.Open()
        comm.CommandText() = sqlstr
        Try
            comm.ExecuteNonQuery()
            MsgBox("Values Inserted Successfully !", MsgBoxStyle.Information, "Success")
        Catch Ex As Exception
            MsgBox(Ex.Message, MsgBoxStyle.Critical, "Error")
        End Try
        comm.Connection.Close() --------------------编程问答-------------------- 说明对应的数据库字段是数值型,而你却输入了普通字符型的内容
检查一下你的这个表里的各个字段类型 --------------------编程问答--------------------  谢谢解决了
补充:VB ,  数据库(包含打印,安装,报表)
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,