Showing posts with label box. Show all posts
Showing posts with label box. Show all posts

Friday, March 30, 2012

How to insert the value from the text box (ASP.NET 2.0) to the microsoft sql server 2000 d

Hello Friends,

I have a problem with ASP.net with dynamic data transfer from asp page to microsoft sql server 2000. For example , I have asp web page with one text field and a buttion.When I click the buttion, the value entered in the text field should be transfered from the text field to database.

Kindly See the following section c# code ....

SqlConnection objconnect = new SqlConnection(connectionString);

SqlCommand cmd = new SqlCommand();

cmd.Connection = objconnect;

cmd.CommandText = " select * from Table_Age where Age = @.Age";

cmd.CommandType = CommandType.Text;

SqlParameter parameter = new SqlParameter();

parameter.ParameterName = "@.Age";

parameter.SqlDbType = SqlDbType.VarChar;

parameter.Direction = ParameterDirection.Output;

parameter.Value = TextBox1.Text;

objconnect.Open();

// Add the parameter to the Parameters collection.

cmd.Parameters.Add(parameter);

SqlDataReader reader = cmd.ExecuteReader();

********************this section c# code is entered under the button control************************************

connection string is mentioned in the web.config file.

In the above c# code , I have a text field , where I entered the age , the value entered in the text field should be sent to database. I have used SqlParameter for selecting the type of data should be sent from ASP.NET 2.0 to the microsoft sql server 2000. I am facing a problem where I am unable to sent the random datas from a text field to the database server.I have a created a database file in the microsoft server 2000.

after the excution of the fIeld value is assinged to NULL in the main database i.e microsoft the sql server 2000.

Can anyone help with this issue.

My mail id phijop@.hotmail.com

- PHIJO MATHEW PHILIP.

Hi

Remove :

parameter.Direction = ParameterDirection.Output;

since your direction should be input.

How to insert numbers from a text box to a Sql database table column’s type numeric?

Hi,

I am getting an error when I try to insert a number typed in a text box control into a Sql database table column's type numeric(6,2). For example: If I type 35,22 into the text box, or 35, and then I submit the form to insert the data into database, I get the follow error:

System.FormatException: Input string was not in a correct format.
Line 428: CmdInsert.Parameters.Add(New SqlParameter("@.Measure", SqlDbType.decimal, "Measure"))

A piece of the SP inside Sql server:


USE market26
GO
ALTER PROC new_offer
@.Offer_id bigint, @.Measure numeric(6,2) = null, …

What is wrong? Why it doesn' t accept the number typed in my text box?

Thank you,
CesarThis is not correct:


CmdInsert.Parameters.Add(New SqlParameter("@.Measure", SqlDbType.Decimal, "Measure"))

This would probably work (not tested):


SqlParameter mParm = new SqlParameter("@.measure", SqlDbType.Decimal);
mParm.Size = 13; // Max size in Bytes of the Decimal number
mParm.Precision = 8; // Total number of digits allowed (right + left of decimal point
mParm.Scale = 2; // Set the number of decimal places the Parameter value is resolved
mParm.set_IsNullable(true);
mParm.Value = decimal.Parse(myTextBox.Text.Trim());

CmdInsert.Parameters.Add(mParm)

|||Hi,

I always write my ASP.NET commands to talk with Sql Stored Procedures thus:


CmdInsert.Parameters.Add(New SqlParameter("@.Measure", SqlDbType.Decimal, "Measure"))

I think that it is correct, and it works fine.

I have never used a text field to insert numeric data into Sql database, but, I have to define all these parameter properties in order to pass a numeric data type to the database?

Thanks|||That's interesting. There is no Constructor attributed to the SqlParameter Class which accepts a Constructor looking like this:


New SqlParameter(<string>,<SqlDbType Enum>, <string>)

as far as I know...But hey, go for it!|||Take a look at this piece of an article and let me know what do you think about it:


Dim sConnectionString As String = _
"server=localhost;uid=sa;pwd=;database=Northwind"
Dim cnNorthwind As New SqlConnection(sConnectionString)
Dim cmdOrders As New SqlCommand("CustOrderHist", cnNorthwind)
cmdOrders.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmCustomerID As New SqlParameter()
prmCustomerID.ParameterName = "@.CustomerID"
prmCustomerID.SqlDbType = SqlDbType.VarChar
prmCustomerID.Size = 5
prmCustomerID.Value = "ALFKI"

cmdOrders.Parameters.Add(prmCustomerID)

Dim daGetOrders As New SqlDataAdapter(cmdOrders)
Dim dsOrders As New DataSet()
daGetOrders.Fill(dsOrders, "Orders")
DataGrid1.DataSource = dsOrders.Tables("Orders")


This example makes all the parameter settings explicit. Some developers like this style, and it's good for instructional purposes. However, some developers prefer an equivalent alternative that has fewer lines of code:

Dim sConnectionString As String = _
"server=localhost;uid=sa;pwd=;database=Northwind"
Dim cnNorthwind As New SqlConnection(sConnectionString)
Dim cmdOrders As New SqlCommand("CustOrderHist", cnNorthwind)
cmdOrders.CommandType = CommandType.StoredProcedure

cmdOrders.Parameters.Add(New _
SqlParameter("@.CustomerID", SqlDbType.VarChar, 5))
cmdOrders.Parameters("@.CustomerID").Value = "ALFKI"

Dim daGetOrders As New SqlDataAdapter(cmdOrders)
Dim dsOrders As New DataSet()
daGetOrders.Fill(dsOrders, "Orders")
DataGrid1.DataSource = dsOrders.Tables("Orders")


This code behaves exactly the same as the previous example. However, it only needs two lines of code for each parameter rather than six. When a stored procedure has a lot of parameters (as some of our later examples do), this can be quite a difference on lines of code required, so we'll use that form from this point onward.

The complete article is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet09102002.asp|||Hey! Perhaps you have misunderstood me. I meant that I always use this structure:
(Which I knew that something was wrong)


CmdInsert.Parameters.Add(New SqlParameter("@.Measure", SqlDbType.Decimal, "Measure"))

Instead of this:

SqlParameter mParm = new SqlParameter("@.measure", SqlDbType.Decimal)
mParm.SourceColumn = "Measure"
CmdInsert.Parameters.Add(mParm)

I knew that something was wrong, I suspected that something it lacked in my SqlParameter, and you helped me with your example!, it lacked only the size property which in my case is 5. I am sorry, the only thing that I saw strange is the structure you wrote, and the amount of parameters which I don' t need to use (in this case). I always use the shorter alternative ;-).

So, the correct SqlParameter in my case is:


CmdInsert.Parameters.Add(New SqlParameter("@.Measure", SqlDbType.Decimal,5, "Measure"))

And now works fine.
Thank you very much!
Cesar

Monday, March 19, 2012

how to improve memory utilization?

We have a SQL 2005 Standard Server, single-processor license, in a
Win2k3 SP1 Standard Server box.
We recently increased its RAM to 4GB and added the /3GB switch to the
boot.ini file.
However, we still receive occasional alerts such as the one below:
Device: SQL
Service: Memory Utilization
State Transition: From Warning To Failed Time Of State Transition:
12/17/06 1:01 AM
Probe(s): 172.16.0.12
Scandetails:
Total Physical Memory (KB): 3145208
Used Physical Memory (KB): 3007896
Free Physical Memory (KB): 137312
Physical Memory Usage (%): 96
Total Virtual Memory (KB): 4190208
Used Virtual Memory (KB): 64500
Free Virtual Memory (KB): 4125708
Virtual Memory Usage (%): 2
Alert: 0
Alert Activated: 12/17/06 1:01 AM
Alert Sent: 12/17/06 1:11 AM
The timing of events like this is not a big deal, it does not affect
end users, but I thought after we increased the available RAM, such
events would go away. And 12/17/06 is a Sunday. There was a test backup
running, but this error has not always appeared during other similar
nightly backups.
So far as I know there are no scheduled activities on the SQL server at
that time, so I am wondering if there is something I should do in the
SQL Server configuration to make it use memory better.
The pagefile is 4GB by the way. I found the Slava Oks blog about SQL
memory but it was over my head.
Thank you, TomIf there is no other usage of the computer, I would recommend reducing the
page file to the minimum -or eliminating it altogether.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"tlyczko" <tlyczko@.gmail.com> wrote in message
news:1166452468.090918.44710@.l12g2000cwl.googlegroups.com...
> We have a SQL 2005 Standard Server, single-processor license, in a
> Win2k3 SP1 Standard Server box.
> We recently increased its RAM to 4GB and added the /3GB switch to the
> boot.ini file.
> However, we still receive occasional alerts such as the one below:
> Device: SQL
> Service: Memory Utilization
> State Transition: From Warning To Failed Time Of State Transition:
> 12/17/06 1:01 AM
> Probe(s): 172.16.0.12
> Scandetails:
> Total Physical Memory (KB): 3145208
> Used Physical Memory (KB): 3007896
> Free Physical Memory (KB): 137312
> Physical Memory Usage (%): 96
> Total Virtual Memory (KB): 4190208
> Used Virtual Memory (KB): 64500
> Free Virtual Memory (KB): 4125708
> Virtual Memory Usage (%): 2
> Alert: 0
> Alert Activated: 12/17/06 1:01 AM
> Alert Sent: 12/17/06 1:11 AM
> The timing of events like this is not a big deal, it does not affect
> end users, but I thought after we increased the available RAM, such
> events would go away. And 12/17/06 is a Sunday. There was a test backup
> running, but this error has not always appeared during other similar
> nightly backups.
> So far as I know there are no scheduled activities on the SQL server at
> that time, so I am wondering if there is something I should do in the
> SQL Server configuration to make it use memory better.
> The pagefile is 4GB by the way. I found the Slava Oks blog about SQL
> memory but it was over my head.
> Thank you, Tom
>|||Really' How come' Would you mind providing some explanation' (or a
link to an explanation)
Is it okay to shrink the pagefile to say 1GB or 512MB' instead of
eliminating it'
Our largest database is around 3GB (Great Plains) but it may someday
take on a SharePoint Services database as well, which could become
quite large, I know.
The box has one single Xeon 2.8 Ghz processor.
We do also have Abra Suite running on it (with FoxPro tables, this is
the server-side part of it, the client runs in Citrix).
(I know SQL does its own memory management etc.)
Thank you, Tom
Arnie Rowland wrote:[vbcol=seagreen]
> If there is no other usage of the computer, I would recommend reducing the
> page file to the minimum -or eliminating it altogether.
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
> You can't help someone get up a hill without getting a little closer to th
e
> top yourself.
> - H. Norman Schwarzkopf
>
> "tlyczko" <tlyczko@.gmail.com> wrote in message
> news:1166452468.090918.44710@.l12g2000cwl.googlegroups.com...

how to improve memory utilization?

We have a SQL 2005 Standard Server, single-processor license, in a
Win2k3 SP1 Standard Server box.
We recently increased its RAM to 4GB and added the /3GB switch to the
boot.ini file.
However, we still receive occasional alerts such as the one below:
Device: SQL
Service: Memory Utilization
State Transition: From Warning To Failed Time Of State Transition:
12/17/06 1:01 AM
Probe(s): 172.16.0.12
Scandetails:
Total Physical Memory (KB): 3145208
Used Physical Memory (KB): 3007896
Free Physical Memory (KB): 137312
Physical Memory Usage (%): 96
Total Virtual Memory (KB): 4190208
Used Virtual Memory (KB): 64500
Free Virtual Memory (KB): 4125708
Virtual Memory Usage (%): 2
Alert: 0
Alert Activated: 12/17/06 1:01 AM
Alert Sent: 12/17/06 1:11 AM
The timing of events like this is not a big deal, it does not affect
end users, but I thought after we increased the available RAM, such
events would go away. And 12/17/06 is a Sunday. There was a test backup
running, but this error has not always appeared during other similar
nightly backups.
So far as I know there are no scheduled activities on the SQL server at
that time, so I am wondering if there is something I should do in the
SQL Server configuration to make it use memory better.
The pagefile is 4GB by the way. I found the Slava Oks blog about SQL
memory but it was over my head. :(
Thank you, TomIf there is no other usage of the computer, I would recommend reducing the
page file to the minimum -or eliminating it altogether.
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"tlyczko" <tlyczko@.gmail.com> wrote in message
news:1166452468.090918.44710@.l12g2000cwl.googlegroups.com...
> We have a SQL 2005 Standard Server, single-processor license, in a
> Win2k3 SP1 Standard Server box.
> We recently increased its RAM to 4GB and added the /3GB switch to the
> boot.ini file.
> However, we still receive occasional alerts such as the one below:
> Device: SQL
> Service: Memory Utilization
> State Transition: From Warning To Failed Time Of State Transition:
> 12/17/06 1:01 AM
> Probe(s): 172.16.0.12
> Scandetails:
> Total Physical Memory (KB): 3145208
> Used Physical Memory (KB): 3007896
> Free Physical Memory (KB): 137312
> Physical Memory Usage (%): 96
> Total Virtual Memory (KB): 4190208
> Used Virtual Memory (KB): 64500
> Free Virtual Memory (KB): 4125708
> Virtual Memory Usage (%): 2
> Alert: 0
> Alert Activated: 12/17/06 1:01 AM
> Alert Sent: 12/17/06 1:11 AM
> The timing of events like this is not a big deal, it does not affect
> end users, but I thought after we increased the available RAM, such
> events would go away. And 12/17/06 is a Sunday. There was a test backup
> running, but this error has not always appeared during other similar
> nightly backups.
> So far as I know there are no scheduled activities on the SQL server at
> that time, so I am wondering if there is something I should do in the
> SQL Server configuration to make it use memory better.
> The pagefile is 4GB by the way. I found the Slava Oks blog about SQL
> memory but it was over my head. :(
> Thank you, Tom
>|||Really' How come' Would you mind providing some explanation' (or a
link to an explanation)
Is it okay to shrink the pagefile to say 1GB or 512MB' instead of
eliminating it'
Our largest database is around 3GB (Great Plains) but it may someday
take on a SharePoint Services database as well, which could become
quite large, I know.
The box has one single Xeon 2.8 Ghz processor.
We do also have Abra Suite running on it (with FoxPro tables, this is
the server-side part of it, the client runs in Citrix).
(I know SQL does its own memory management etc.)
Thank you, Tom
Arnie Rowland wrote:
> If there is no other usage of the computer, I would recommend reducing the
> page file to the minimum -or eliminating it altogether.
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
> You can't help someone get up a hill without getting a little closer to the
> top yourself.
> - H. Norman Schwarzkopf
>
> "tlyczko" <tlyczko@.gmail.com> wrote in message
> news:1166452468.090918.44710@.l12g2000cwl.googlegroups.com...
> > We have a SQL 2005 Standard Server, single-processor license, in a
> > Win2k3 SP1 Standard Server box.
> >
> > We recently increased its RAM to 4GB and added the /3GB switch to the
> > boot.ini file.
> >
> > However, we still receive occasional alerts such as the one below:
> >
> > Device: SQL
> > Service: Memory Utilization
> > State Transition: From Warning To Failed Time Of State Transition:
> > 12/17/06 1:01 AM
> > Probe(s): 172.16.0.12
> >
> > Scandetails:
> > Total Physical Memory (KB): 3145208
> > Used Physical Memory (KB): 3007896
> > Free Physical Memory (KB): 137312
> > Physical Memory Usage (%): 96
> > Total Virtual Memory (KB): 4190208
> > Used Virtual Memory (KB): 64500
> > Free Virtual Memory (KB): 4125708
> > Virtual Memory Usage (%): 2
> >
> > Alert: 0
> > Alert Activated: 12/17/06 1:01 AM
> > Alert Sent: 12/17/06 1:11 AM
> >
> > The timing of events like this is not a big deal, it does not affect
> > end users, but I thought after we increased the available RAM, such
> > events would go away. And 12/17/06 is a Sunday. There was a test backup
> > running, but this error has not always appeared during other similar
> > nightly backups.
> >
> > So far as I know there are no scheduled activities on the SQL server at
> > that time, so I am wondering if there is something I should do in the
> > SQL Server configuration to make it use memory better.
> >
> > The pagefile is 4GB by the way. I found the Slava Oks blog about SQL
> > memory but it was over my head. :(
> >
> > Thank you, Tom
> >

how to improve memory utilization?

We have a SQL 2005 Standard Server, single-processor license, in a
Win2k3 SP1 Standard Server box.
We recently increased its RAM to 4GB and added the /3GB switch to the
boot.ini file.
However, we still receive occasional alerts such as the one below:
Device: SQL
Service: Memory Utilization
State Transition: From Warning To Failed Time Of State Transition:
12/17/06 1:01 AM
Probe(s): 172.16.0.12
Scandetails:
Total Physical Memory (KB): 3145208
Used Physical Memory (KB): 3007896
Free Physical Memory (KB): 137312
Physical Memory Usage (%): 96
Total Virtual Memory (KB): 4190208
Used Virtual Memory (KB): 64500
Free Virtual Memory (KB): 4125708
Virtual Memory Usage (%): 2
Alert: 0
Alert Activated: 12/17/06 1:01 AM
Alert Sent: 12/17/06 1:11 AM
The timing of events like this is not a big deal, it does not affect
end users, but I thought after we increased the available RAM, such
events would go away. And 12/17/06 is a Sunday. There was a test backup
running, but this error has not always appeared during other similar
nightly backups.
So far as I know there are no scheduled activities on the SQL server at
that time, so I am wondering if there is something I should do in the
SQL Server configuration to make it use memory better.
The pagefile is 4GB by the way. I found the Slava Oks blog about SQL
memory but it was over my head.
Thank you, Tom
If there is no other usage of the computer, I would recommend reducing the
page file to the minimum -or eliminating it altogether.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"tlyczko" <tlyczko@.gmail.com> wrote in message
news:1166452468.090918.44710@.l12g2000cwl.googlegro ups.com...
> We have a SQL 2005 Standard Server, single-processor license, in a
> Win2k3 SP1 Standard Server box.
> We recently increased its RAM to 4GB and added the /3GB switch to the
> boot.ini file.
> However, we still receive occasional alerts such as the one below:
> Device: SQL
> Service: Memory Utilization
> State Transition: From Warning To Failed Time Of State Transition:
> 12/17/06 1:01 AM
> Probe(s): 172.16.0.12
> Scandetails:
> Total Physical Memory (KB): 3145208
> Used Physical Memory (KB): 3007896
> Free Physical Memory (KB): 137312
> Physical Memory Usage (%): 96
> Total Virtual Memory (KB): 4190208
> Used Virtual Memory (KB): 64500
> Free Virtual Memory (KB): 4125708
> Virtual Memory Usage (%): 2
> Alert: 0
> Alert Activated: 12/17/06 1:01 AM
> Alert Sent: 12/17/06 1:11 AM
> The timing of events like this is not a big deal, it does not affect
> end users, but I thought after we increased the available RAM, such
> events would go away. And 12/17/06 is a Sunday. There was a test backup
> running, but this error has not always appeared during other similar
> nightly backups.
> So far as I know there are no scheduled activities on the SQL server at
> that time, so I am wondering if there is something I should do in the
> SQL Server configuration to make it use memory better.
> The pagefile is 4GB by the way. I found the Slava Oks blog about SQL
> memory but it was over my head.
> Thank you, Tom
>
|||Really? How come? Would you mind providing some explanation? (or a
link to an explanation)
Is it okay to shrink the pagefile to say 1GB or 512MB? instead of
eliminating it?
Our largest database is around 3GB (Great Plains) but it may someday
take on a SharePoint Services database as well, which could become
quite large, I know.
The box has one single Xeon 2.8 Ghz processor.
We do also have Abra Suite running on it (with FoxPro tables, this is
the server-side part of it, the client runs in Citrix).
(I know SQL does its own memory management etc.)
Thank you, Tom
Arnie Rowland wrote:[vbcol=seagreen]
> If there is no other usage of the computer, I would recommend reducing the
> page file to the minimum -or eliminating it altogether.
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
> You can't help someone get up a hill without getting a little closer to the
> top yourself.
> - H. Norman Schwarzkopf
>
> "tlyczko" <tlyczko@.gmail.com> wrote in message
> news:1166452468.090918.44710@.l12g2000cwl.googlegro ups.com...