I have a problem to put datsa to my database

  • Thread starter Thread starter Matthias Roeder
  • Start date Start date
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
 
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.
 
Back
Top