开发者

My Sql Database Table Will Not Show Data That I Wish To Insert Into It With VB 2008 Express

I'm quite new into the programming game, I've been working on this program for a few weeks now, and its coming along, but the method I searched for entering new rows of data into my table doesn't seem to update my tables after I try entering data. I have a feeling it may be something very simple that i am over looking. Any help would be greatly appreciated. Thanks

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
   Handles Button4.Click

    Dim conn As New SqlConnection("my datasource")
    Dim comm As New SqlCommand()

    comm.Connection = conn

    comm.CommandText() = "INSERT INTO inventoryTable(item, itemDescription, quantity, purchasePrice, markUp, sellingPrice, paymentMethod, paymentAmount) VALUES (@ParameterItem,@ParameterItemD,@ParameterQuan,@ParameterPurch,@ParameterMark,@ParameterSell,@ParameterPm,@ParameterPa)"

    comm.Parameters.AddWithValue("@ParameterItem", TextBox1.Text)
    comm.Parameters.AddWithValue("@ParameterItemD", TextBox8.Text)
    comm.Parameters.AddWithValue("@ParameterQuan", TextBox2.Text)
    comm.Parameters.AddWithValue("@ParameterPurch", TextBox3.Text)
    comm.Parameters.AddWithValue("@ParameterMark", TextBox4.Text)
    comm.Parameters.AddWithValue("@ParameterSell", TextBox5.Text)
    comm.Parameters.AddWithValue("@ParameterPm", ComboBox2.Text)
    comm.Parameters.AddWithValue("@ParameterPa", TextBox6.Text)

    Try

        conn.Open()
        comm.ExecuteNonQuery()
        conn.Close()

    Catch ex As Exception

        MsgBox(ex.Message)

    End Try

    'TextBox7.Text = TextBox1.Text + ", " + TextBox8.Text + ", " + TextBox开发者_运维问答2.Text + ", " + TextBox3.Text + ", " + TextBox4.Text + ", " + TextBox5.Text + ", " + ComboBox2.Text + ", " + TextBox6.Text

End Sub


If that is your verbatim code, then the problem is in the connection string. You'd need to replace "my datasource" with an actual connection string. Check out this website for help on creating a connection string:

http://www.connectionstrings.com/

Disregard this as silliness if you simply removed the connection string before posting on here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜