I have a problem to put datsa to my database

M

Matthias Roeder

Hi group,

I'm getting datas form a differentserver as Html code.

I need ti write the datas in a database.

code:
Dim InsertCmd As String = "insert into table(cell1) values(@value1)


Dim MyCommand As SqlCommand

MyCommand = New SqlCommand(InsertCmd, MyConnection)

MyCommand.Parameters.Add(New
SqlParameter("@merchant",SqlDbType.NVarChar, 11))
MyCommand.Parameters("@value1").Value

MyConnection.Open()

my problem is, the html form doesn't support the form_name.value Method.
so what i tried is:
code:

Dim field1 AS String =Request.Form("field1")


Dim MyCommand As SqlCommand

MyCommand = New SqlCommand(InsertCmd, MyConnection)

MyCommand.Parameters.Add(New
SqlParameter("@merchant",SqlDbType.NVarChar, 11))
MyCommand.Parameters("@value1").Value = field1

MyConnection.Open()

but it doesn't work, I don't know now what I have to do.
sorry for my bad english, but I hope you can understand what my problem is.
thanks for you help

bye
Matthias




bye
 
M

Miha Markic

Hi Matthias,

Inline

Matthias Roeder said:
Hi group,

I'm getting datas form a differentserver as Html code.

I need ti write the datas in a database.

code:
Dim InsertCmd As String = "insert into table(cell1) values(@value1)


Dim MyCommand As SqlCommand

MyCommand = New SqlCommand(InsertCmd, MyConnection)

MyCommand.Parameters.Add(New
SqlParameter("@merchant",SqlDbType.NVarChar, 11))

should be @value1 (and not @merchant)
MyCommand.Parameters("@value1").Value

MyConnection.Open()

You have to invoke MyCommand.ExecuteNonQuery(); to fire the insert.
my problem is, the html form doesn't support the form_name.value Method.
so what i tried is:
code:

Dim field1 AS String =Request.Form("field1")


Dim MyCommand As SqlCommand

MyCommand = New SqlCommand(InsertCmd, MyConnection)

MyCommand.Parameters.Add(New
SqlParameter("@merchant",SqlDbType.NVarChar, 11))

should be @value1 (and not @merchant)
MyCommand.Parameters("@value1").Value = field1

MyConnection.Open()

but it doesn't work, I don't know now what I have to do.
sorry for my bad english, but I hope you can understand what my problem is.
thanks for you help


You have to invoke MyCommand.ExecuteNonQuery(); to fire the insert.
And don't forget to close the connection afterwards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top