I have been now reading MSDN and understand that the way to go is always
to open/close connection as the pool itself takes care of it.
with help of sample in MSDN I got this to work
String fullname = TxtBox_name.Text;
String email = TxtBox_email.Text;
String phone = TxtBox_phone.Text;
String pwd = TxtBox_pwd.Text;
System.Configuration.Configuration rootWebConfig
=System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot");
System.Configuration.ConnectionStringSettings connString;
if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count
> 0)
{
connString
=rootWebConfig.ConnectionStrings.ConnectionStrings["ConnectionString2"];
if (connString != null)
{
using (FbConnection conn = new
FbConnection(connString.ConnectionString))
{
conn.Open();
using (FbCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from
SP_PARTY_INS (?, ?, ?, ?, ?);";
cmd.Parameters.Add("@email", email);
cmd.Parameters.Add("@name", fullname);
cmd.Parameters.Add("@websiteurl", null);
cmd.Parameters.Add("@phone", phone);
cmd.Parameters.Add("@pwd", pwd);
int i = (int)cmd.ExecuteScalar();
if (i != null)
{
Button2.Text = "New user id: " + i;
}
}
conn.Close();
}
}
}
however is there any advantages of using FbCommand over just doing with
Visual Studio SqlDataSource command? because this code is a lot shorter
String fullname=TxtBox_name.Text;
String email=TxtBox_email.Text;
String phone=TxtBox_phone.Text;
String pwd = TxtBox_pwd.Text;
SqlDataSource1.SelectParameters.Add("@email", email);
SqlDataSource1.SelectParameters.Add("@name", fullname);
SqlDataSource1.SelectParameters.Add("@websiteurl", null);
SqlDataSource1.SelectParameters.Add("@phone", phone);
SqlDataSource1.SelectParameters.Add("@pwd", pwd);
DataView dv =
(DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
int i = (int)dv.Table.Rows[0][0];
if (i != null)
{
Button1.Text = "New user id: " + i;
}
is there any difference in performance? or some other advantage?
On 18.12.2011 11:19, Jiri Cincura wrote:
> On Sun, Dec 18, 2011 at 12:20 AM, Net Newbie<[email protected]> wrote:
>> how to do this in a better way?
> Look at connection pooling topic at MSDN.
>
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider