F
fniles
I am using VB.NET 2003 and SQL2000 database.
I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1
parameter (varchar(10)) and returns the identity column value from that
table.
When calling the stored procedure from VB.NET, in the CommandText, can I
just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with
"INSERT_INTO_MYTABLE" then do the following :
OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)
OleDbCommand2.Parameters("@Account").Value = "12345"
? Because if I have many parameters,it is a lot of work to set each
parameter like the above.
I tried it, but it gave me an error.
Thanks.
Dim OleDbCommand2 As New Data.SqlClient.SqlCommand
Dim OleDbConnection1 As New Data.SqlClient.SqlConnection
Dim m_daSQL As SqlClient.SqlDataAdapter
Dim m_dsSQL As DataSet
With OleDbConnection1
.ConnectionString = "...."
.Open()
End With
OleDbCommand2.CommandText = "INSERT_INTO_MYTABLE" ------> CAN I set
it to INSERT_INTO_MYTABLE '12345' ?
OleDbCommand2.CommandType = CommandType.StoredProcedure
OleDbCommand2.Connection = OleDbConnection1
OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)
OleDbCommand2.Parameters("@Account").Value = "12345"
m_daSQL = New SqlClient.SqlDataAdapter
m_dsSQL = New DataSet
m_daSQL.SelectCommand = OleDbCommand2
m_daSQL.Fill(m_dsSQL)
I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1
parameter (varchar(10)) and returns the identity column value from that
table.
When calling the stored procedure from VB.NET, in the CommandText, can I
just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with
"INSERT_INTO_MYTABLE" then do the following :
OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)
OleDbCommand2.Parameters("@Account").Value = "12345"
? Because if I have many parameters,it is a lot of work to set each
parameter like the above.
I tried it, but it gave me an error.
Thanks.
Dim OleDbCommand2 As New Data.SqlClient.SqlCommand
Dim OleDbConnection1 As New Data.SqlClient.SqlConnection
Dim m_daSQL As SqlClient.SqlDataAdapter
Dim m_dsSQL As DataSet
With OleDbConnection1
.ConnectionString = "...."
.Open()
End With
OleDbCommand2.CommandText = "INSERT_INTO_MYTABLE" ------> CAN I set
it to INSERT_INTO_MYTABLE '12345' ?
OleDbCommand2.CommandType = CommandType.StoredProcedure
OleDbCommand2.Connection = OleDbConnection1
OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)
OleDbCommand2.Parameters("@Account").Value = "12345"
m_daSQL = New SqlClient.SqlDataAdapter
m_dsSQL = New DataSet
m_daSQL.SelectCommand = OleDbCommand2
m_daSQL.Fill(m_dsSQL)