Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Insert data into database

  Asked By: Ira    Date: Sep 08    Category: Asp.net    Views: 5846
  

a quite simple question, but i don't find the answer
I have to insert some data to a database, using stored procedures and
Commandobject...

Now, i've a problem with the primary key of the table.
As i don't know it, i can't fill in one, and when in fill in "" or objArray(0) =
nothing, i get some mistakes...

What do i have to fill in or change into my DataBase?

CODE SNIPPET:



'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "[MyMovieInsertCmd]"
Me.SqlInsertCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int,
4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0,
Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieID", System.Data.SqlDbType.Int, 4,
"movieID"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@userID", System.Data.SqlDbType.Int, 4,
"userID"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieName", System.Data.SqlDbType.VarChar,
20, "movieName"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieAantalCD", System.Data.SqlDbType.Int,
4, "movieAantalCD"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieFrameRate",
System.Data.SqlDbType.VarChar, 10, "movieFrameRate"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieCodec", System.Data.SqlDbType.VarChar,
10, "movieCodec"))
'



Dim objArray(5) As Object

objArray(0) = ??????????????????????

objArray(1) = CType(txtuserID.Text, Integer) '"userID"
objArray(2) = CType(txtName.Text, String) '"movieName"
objArray(3) = CType(txtAantalCD.Text, Integer) '"movieAantalCds"
objArray(4) = CType(txtFrameRate.Text, String) '"movieFrameRate"
objArray(5) = CType(txtCodec.Text, String) '"movieCodec"


MyDS1 = CType(Session("MyDataSet"), DataSet)
Dim myDataTable As DataTable = MyDS1.Tables("FilmTabel")
myDataTable.Rows.Add(objArray)
'Steek opnieuw in de Session
Session("MyDataSet") = MyDS1
'Update de Gegevens
SqlDataAdapter1.Update(myDataTable)

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Insert data into database Or get search suggestion and latest updates.




Tagged: