Showing posts with label textbox. Show all posts
Showing posts with label textbox. Show all posts

Wednesday, March 21, 2012

problem with a date parameter in ASP.Net page

The date format in the 'weekending' textbox is 5/5/2007
Here's what I've got:

With cmd.Parameters
.Add(New SqlParameter("@.SQLweekending", SqlDbType.DateTime,weekending.Text))
the error message is:
"Conversion from string "4/8/2007" to type 'Integer' is not valid."

Then, I tried:
.Add(

New SqlParameter("@.SQLweekending", SqlDbType.DateTime,CDate(weekending.Text)))

but, before I even tried it, it gave me a blue squiggly line, with an error message:
"Error 2 Value of type 'Date' cannot be converted to 'Integer'"

How can I get this to work?

Hi,

What is the data type for yourSQLweekending column in your table? Is it a DateTime column or Integer type? You need a DateTime column for this.

|||Nope - it's datetime also|||

Here is sample in VB.NET that inserts date to a datetime column:

Dim MySQLAsString ="Insert into Dates (id, tDate) values (@.id, @.tDate)"Dim myConnAs SqlConnection =New SqlConnection(ConfigurationManager.ConnectionStrings("forumConnectionString").ConnectionString.ToString())Dim CmdAsNew SQLCommand(MySQL, MyConn)

Cmd.Parameters.Add(

New SqlParameter("@.id", txtid.Text))

Cmd.Parameters.Add(

New SqlParameter("@.tDate",txttDate.Text))

MyConn.Open()

cmd.ExecuteNonQuery()

MyConn.Close()sql

Monday, February 20, 2012

Problem using Count in code

When I set the contents of a textbox on my report to

count(Fields!DepartmentID.Value, "Departments")

my report runs.

However, when I try to use the same expression in my code, I keep getting the following compiler error:

[BC30451] Name 'Count' is not declared.

Do I need to qualify the Count function with an assembly path? If so, what is it?

Thx

Helen

When you write code behind the report you are strictly writing VB. Count is not a method in VB.|||

I understand, but since a code expression in the report itself can call it, I wonder if I can reference an assembly so that my code-behind can also call it? It's got to be available somewhere.

thx

Helen