How can I translate this from classic asp?

  • Thread starter Fabrizio Maccarrone
  • Start date
F

Fabrizio Maccarrone

Hallo,

I'm trying to migrate from classic asp to asp net.

How can I write this instruction in classic asp, using a command object, to
asp net?

===========================================
'....................
Set cmd = Server.CreateObject("ADODB.Command")
cmd.CommandType = adCmdStoredProc
cmd.ActiveConnection = conn

With cmd
.CommandText = "Misc_Errori_Comuni_Dove"
.Parameters.Append
..CreateParameter("@Param1",adVarWChar,adParamInput,50,myInput)
Set Rs = .Execute
End With

for pc = cmd.Parameters.Count - 1 to 0 step -1
cmd.Parameters.Delete pc
next
'....................
===========================================


Any help much appreciated.

Best regards.
 
B

Ben Lucas

Take a look at the System.Data.SqlClient namespace in the Visual Studio.NET
help files. You would use a SqlCommand and your code would depend on how
you wanted to go through the data. You can either get a SqlDataReader
object which will allow you to iterate through the records one at a time.
Or you could get a DataSet which operates more like a database structure (it
has tables and relations, for example)

The following code provides an example of using the SqlDataReader

dim conn as new SqlConnection(CONNECTION_STRING)
dim cmd as new SqlCommand("Misc_Errori_Comuni_Dove", conn)
dim param as SqlParameter
cmd.CommandType = CommandType.StoredProcedure
param = new SqlParameter("@Param1", SqlDbType.NVarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = myInput
cmd.Parameters.Add(param)
conn.Open()
dim reader as SqlDataReader = cmd.ExecuteReader()
Try
while reader.Read()
'Process the record
end while
finally
reader.Close()
conn.Close()
end try

Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com
 

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top