TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mr Anderson
NA
28
570
Values Not being passed Correctly
Sep 20 2017 11:06 AM
The issue I am having is the values from are not being passed into my array correctly. I've done a Response.Write to check and I have the correct data. I can not seem to get this to pass into my array or the database correctly.My goal is to pass ID and P into an array and in the for loop through them then output the corresponding data. What is showing up for P is 0. I am using razor C# without MVC.
else
if
(Page ==
"2"
)
{
int
foo;
string
paramName =
""
;
using
(SqlConnection connect =
new
SqlConnection(conn.strConn))
{
connect.Open();
using
(SqlCommand comm =
new
SqlCommand(conn.SQL, connect))
{
using
(SqlDataReader reader = comm.ExecuteReader())
{
reader.Read();
foo = Convert.ToInt32(reader[
"bar"
]);
}
}
}
string
[] ID =
new
string
[foo];
double
[] P =
new
double
[foo];
i = 0;
if
(!HttpContext.Current.Request[
"bar"
].IsEmpty())
{
foreach
(var selection
in
HttpContext.Current.Request[
"bar"
].Split(
','
))
{
IDs[i] = selection.ToString();
ID = selection.ToString();
paramName =
"P"
+ ID;
Ps[i] = Convert.ToDouble(HttpContext.Current.Request[paramName]);
P = Convert.ToDouble(HttpContext.Current.Request[paramName]);
i++;
//insert into Table
conn.SQL =
"Insert Into Table (ID, Date, Number ) Values (@ID, @Dt, @Nm)"
;
using
(SqlConnection connection =
new
SqlConnection(conn.strConn))
{
connection.Open();
using
(SqlCommand comm =
new
SqlCommand(conn.SQL, connection))
{
comm.Parameters.AddWithValue(
"@ID"
, ID);
comm.Parameters.AddWithValue(
"@Dt"
, DateTime.Now);
comm.Parameters.AddWithValue(
"@Nm"
, Math.Round(P, 2));
comm.ExecuteNonQuery();
}
}
}
conn.SQL =
"Select Name, Name1 From Table2 Where ID = @ID"
;
"0"
>
class
=
"d0"
>
"250px"
>
Name
Data
@
for
(
int
x = 0; x < i; x++)
{
using
(SqlConnection connection =
new
SqlConnection(conn.strConn))
{
connection.Open();
using
(SqlCommand comm =
new
SqlCommand(conn.SQL, connection))
{
comm.Parameters.AddWithValue(
"@ID"
, IDs[x]);
using
(SqlDataReader reader = comm.ExecuteReader())
{
reader.Read();
class
=
"d@((x+1)%2)"
>
@(reader[
"Name"
] +
" "
+ reader[
"Name1"
])
@Ps[x].ToString(
"c"
)
//Response.Write(@Ps[x]);
}
}
}
}
}
}
Reply
Answers (
2
)
I am unable to Install Newtonsoft.Json 10.0.3 via NuGet
Copy to Clipboard Functionality