Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim conn As New OleDbConnection("Data Source=""" & Me.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings("database")) & """;Provider=""Microsoft.Jet.OLEDB.4.0"";User ID=Admin")
        If Not Me.TextBox2.Text.Length > 0 Then
            Me.TextBox2.Text = System.DBNull.Value.ToString
        End If
        Dim mycom As New OleDbCommand("INSERT INTO T_links (WebName, WebUrl) VALUES ('" & Me.TextBox1.Text & "','" & Me.TextBox2.Text & "')", conn)
        conn.Open()
        If mycom.ExecuteNonQuery > 0 Then
            Me.Label1.Text = "成功 "
        End If
        conn.Close()

解决方案 »

  1.   

    System.DBNull.Value
    插入这个就可以了,no tostring吧
      

  2.   

    有错误啊  ,类型System.DBNull 无法转换成string
      

  3.   

    If Not Me.TextBox2.Text.Length > 0 Then
                Me.TextBox2.Text = System.DBNull.Value.ToString
            End If
    这一句有什么用??要验证他输入的是否非空,在客户端就该验证了啊。
      

  4.   

    空值用,
    me.textbox.text=""就行了啊!!
      

  5.   

    If Not Me.TextBox2.Text.Length > 0 Then
                Me.TextBox2.Text = System.DBNull.Value.ToString
            End If-----------------------------------这一句不要就可以了.