Seriallization of SLQCommand Object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi ;

I'm trying to figurer out a way to serialize the SqlCommand object:

Myu objective is to create a SqlCommand object set up the CommandText, all
needed Parameters with there values then Serialize the objet to binary format
save into a SQL server Database for later use i.e. data Transfer.

So far no success because the error says the the object is not marked with
<Serialize>
 
Can't do it. You would have to implement ISerializable for the class and the
SQLCommand class is sealed (Not Inheritable).

You would be better off, if this is necessary, saving the values of
properties somewhere so that your program can setup the Command objects with
values from outside of code.

I use an XML file to contain connection parameters. In the program, I build
the connections string using the XML based values. Briefly:

strConn = System.Configuration.ConfigurationSettings.AppSettings("strConn")
& _
";user id=" & _
System.Configuration.ConfigurationSettings.AppSettings"mappedName") & _
";password=" & _
System.Configuration.ConfigurationSettings.AppSettings("mappedKey") & _
";Data Source=" & _

System.Configuration.ConfigurationSettings.AppSettings("mappedInstance") & _
";Initial Catalog=" & _
System.Configuration.ConfigurationSettings.AppSettings("mappedCat")

For saving this in SQL Server, map out the command and normalize the
structure. Two tables: Command and Parameters in a 1 to many relationship
(Command on the 'one' side) would store all the components you need to build
a command. Other tables could include the command text (SPs or SQL).
 
Back
Top