How To Format A String When Pulling From A Dataitem
Mar 24, 2006
I seem to be having a problem in getting a string formatted correctly that I'm pulling from a SQL Datasource.
I'm trying to format a Datalist, and more specifically, a Paypal "Add to Cart" button that's supposed to pass several values to another page. The problem I have is with passing the price amount. All the data is in a SQL Express database and the price field is in the database as "money". However it outputs the dollar amount with too many trailing zeros, for example $6.00 is formatted as 6.0000. I'm trying to pass it into the form variable with this code:
<input type="hidden" name="amount" value="<%# DataBinder.eval(Container.dataitem, "Price", "{0}" %>">
Unfortunately, that tends to make include the trailing zeros and mess up the ability to pass the variable. Can anyone help me with how to format this variable so there's no trailing zeros, just so that $6.00 comes out as 6.00 and not 6.0000?
Thanks
View 2 Replies
ADVERTISEMENT
Sep 2, 2005
I am currently building an ecommerce site using aspx, vbscript, & sql.
In my productlist control containing a datalist I am trying to use an if
statement to determine if products are from a certain supplier... and
if they are; display a phone number to call for pricing rather than the
price, since this particular supplier doesnt allow pricing of their
products online.
This is what I have now:
<%
Dim objConn
objConn = Server.CreateObject("ADODB.Connection")
Dim strConnect
strConnect = ConfigurationSettings.AppSettings("ConnectionString")
Dim supplier
objConn.Open(strConnect)
supplier = objConn.Execute("Select SupplierID From Product")
If supplier = "C" Then
Response.Write("Call 1-800-POO-STAIN")
Else
Response.Write(" Sug. Retail:")
DataBinder.Eval(Container.DataItem, "Price")
End IF
objConn.Close
objConn = Nothing
%>
This code gives me the following error message:
The component 'ADODB.Connection' cannot be created. Apartment threaded
components can only be created on pages with an <%@ Page aspcompat=true %>
page directive
Can anybody help me get this working?
I haven't worked with VBScript for acouple years now and I'm a little rusty.
Any help would be greatly appreciated
View 3 Replies
View Related
Jun 15, 2005
I have date coming to one page as a string in the following format"May 4 2005 12:00AM"
I need to query one of my tables using this date in combination of other nondate values. How can I convert this date into valid sql server datetime format before I query a database tables
Please help
View 3 Replies
View Related
Jun 4, 2015
I have a table which stores date-of-birth in varchar 19861231(yyyymmdd). A view takes this data. I want to store this date as mmddyyyy in the view. How can we achieve this?
View 18 Replies
View Related
Aug 8, 2000
I have to convert From Sybase to SQL Server and I've got fields type in Sybase which are long varchar (length around 60000).
At first, I convert in format text but SQL Server refused to pass this type for parameters in stored procedures when i need that. So I have used varchar(8000) in stored procedures. But I'm afraid it would be truncated in the application.
So what is long varchar in SQL Server and how to use that by optimistic way ?
Thanks
Axel
View 2 Replies
View Related
Oct 22, 2004
I have a column in a database that is a phone number. The problem is that it is stored like so
4589958
Anyway that I can insert a "-" after the first 3 digits in SQL SELECT statement
View 3 Replies
View Related
May 22, 2007
I have this line in my script component and it's not producing the number with dashes.
Row.TAXIDNO = String.Format("{0##-##-####}", Row.TAXIDNO)
What the hell is going on?
Thanks.
View 4 Replies
View Related
Nov 14, 2006
Hai
I have a table call TimeMgt, and i have got a field name call TimeDifference like this:
TimeDifference (varchar(255))
------------------
10.230
10.856222
25.355542
85.2455
12.98888882542533
Now need to get this out put
TimeDifference
------------------
10.23
10.85
25.35
85.24
12.98
In this case i cant use cast(TimeDifference as decimal(16,2))
becasse eg :
12.98888882542533 values after writing this sql cast(TimeDifference as decimal(16,2))
gives me this result ===== 12.99====wrong!
i want to display like this 12.98
Ho do I do this task ? what is the best way to format like this ? Is there any straight methods to do this task ?
sujithf
View 5 Replies
View Related
Oct 18, 2007
HI!
I do a select and concatinating the answers into a one column table @tab(string).
Is it possible to format these values like this:
GENAV DELAV TOTIP RES
12 myvalues www.notech.com 1
1 starthere 192.168.0.2 1
125 or here www.hereistomanychar.s 0
max 3 max 10 max 22 max 1
the first column max 3 characters the second column max 10 char...
I want to do this to get a good view of the data i the table @tab
Here is the select:
INSERT INTO @tab
SELECT Convert( varchar, GENAV)+ ' ' + Convert( varchar, DELAV)+ ' ' + Convert( varchar, TOTIP) ' ' + Convert( varchar, RES)
from dbo.MOVE
where DATE between @starttime and @theEndTime
With this select it looks like:
12 myvalues www.notech.com 1
1 starthere 192.168.0.2 1
125 or here www.hereistomanychar.s 0
This is very complicated to read!
View 6 Replies
View Related
Feb 6, 2008
Hi,
I'm retrieving data from a cube using a datareader, all the measures have format string, but when retrieve from Integration services it's lost.
I know there is a way to get the format string as columns using extended properties of the conection. I haven't tried this yet, but is there any way of reapplying this format to the columns using this format strings??
thanks
View 3 Replies
View Related
Aug 8, 2006
I get this error when executing a stored procedure from my code. I suppose something's going wrong with data types, but I cannot see what. If anyone has a sharper eye and can see what it is, please let me know. Thanks in advance!Here is a code excerpt: int category = Convert.ToInt32(ddlCategories.SelectedValue); int museum = Convert.ToInt32(ddlMuseums.SelectedValue); int collection = Convert.ToInt32(ddlCollections.SelectedValue); string binomen = txtScientName.Text; string locality = txtLocality.Text; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@taxparent", category)); command.Parameters.Add(new SqlParameter("@museum", museum)); command.Parameters.Add(new SqlParameter("@collection", collection)); command.Parameters.Add(new SqlParameter("@binomen", binomen)); command.Parameters.Add(new SqlParameter("@locality", locality));And the stored procedure code: ALTER PROCEDURE [petrander].[DynamicQuery] @taxparent int = NULL, @museum int = NULL, @collection int = NULL, @binomen Nvarchar(254) = NULL, @locality Nvarchar(254) = NULLAS SELECT * FROM QueryView WHERE InstitutionCode = COALESCE(@museum, InstitutionCode) AND CollectionCode = COALESCE(@collection, CollectionCode) AND ScientificName LIKE '%' + @binomen + '%' AND Locality LIKE '%' + @locality + '%' AND ParentID1 = COALESCE(@taxparent, ParentID3) OR ParentID2 = COALESCE(@taxparent, ParentID2) OR ParentID3 = COALESCE(@taxparent, ParentID3) OR ParentID4 = COALESCE(@taxparent, ParentID4) OR ParentID5 = COALESCE(@taxparent, ParentID5) OR ParentID6 = COALESCE(@taxparent, ParentID6) OR ParentID7 = COALESCE(@taxparent, ParentID7) OR ParentID8 = COALESCE(@taxparent, ParentID8)
View 1 Replies
View Related
Dec 28, 2006
HiI have just started using Visual Web Developer to produce
asp.net page. I am having a problem when inserting a new record into a
particular table, within the insertion form I have included a drop down
list which gathers informaton from another table. When I view the page
through the browser when I click the insert link I get an error message
on stating 'Input string not in correct format' . The code for the page is below. Does anyone know what
the problem could be? Thanks <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="PhotoAdmin_Default" title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:Label ID="UserIdValue" runat="server"></asp:Label><br /> <asp:SqlDataSource ID="pictureDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [Pictures] WHERE [PictureID] = @PictureID" InsertCommand="INSERT INTO [Pictures] ([UserId], [CategoryID], [Title], [Description], [UploadedOn]) VALUES (@UserId, @CategoryID, @Title, @Description, @UploadedOn)" SelectCommand="SELECT * FROM [Pictures] WHERE ([UserId] = @UserId) ORDER BY [UploadedOn] DESC" UpdateCommand="UPDATE [Pictures] SET [UserId] = @UserId, [CategoryID] = @CategoryID, [Title] = @Title, [Description] = @Description, [UploadedOn] = @UploadedOn WHERE [PictureID] = @PictureID"> <DeleteParameters> <asp:Parameter Name="PictureID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="UserId" /> <asp:Parameter Name="CategoryID" Type="Int32" /> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="UploadedOn" Type="DateTime" /> <asp:Parameter Name="PictureID" Type="Int32" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text" /> </SelectParameters> <InsertParameters> <asp:Parameter Name="UserId" /> <asp:Parameter Name="CategoryID" Type="Int32" /> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="UploadedOn" Type="DateTime" /> </InsertParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="categoriesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] ORDER BY [Name]"> </asp:SqlDataSource> <asp:SqlDataSource ID="maxPictureIDDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT MAX (PictureID) FROM Pictures WHERE UserId = @UserId"> <SelectParameters> <asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text" /> </SelectParameters> </asp:SqlDataSource> <br /> <asp:DetailsView ID="dvPictureInsert" runat="server" AutoGenerateRows="False" DataKeyNames="PictureID" DataSourceID="pictureDataSource" DefaultMode="Insert" Height="50px" Width="125px"> <Fields> <asp:BoundField DataField="PictureID" HeaderText="PictureID" InsertVisible="False" ReadOnly="True" SortExpression="PictureID" /> <asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="categoriesDataSource" DataTextField="Name" DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>' AppendDataBoundItems="True"> <asp:ListItem>--None--</asp:ListItem> </asp:DropDownList> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Title" SortExpression="Title"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox><br /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="PictureAdd"></asp:RequiredFieldValidator> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("Title") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Description" SortExpression="Description"> <EditItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox><br /> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="PictureAdd"></asp:RequiredFieldValidator> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Bind("Description") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:CommandField ShowInsertButton="True" /> </Fields> </asp:DetailsView> <br /> <br /></asp:Content>
View 3 Replies
View Related
May 21, 2007
I am using SQL Server Express and Visual Web Developer Express with VB as my preferred language.
I am trying to specify an InsertParameter with a querystring parameter of a SQLDataSource Control.
My Code is:
<InsertParameters>
<asp:Parameter Name="ProjectID" Type="Int32" DefaultValue="Convert.ToInt32(Label1.Text)" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Size" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
I get the error message above and the detail is:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2753299
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
System.String.System.IConvertible.ToInt32(IFormatProvider provider) +43
System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +293
System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +248
System.Web.UI.WebControls.Parameter.get_ParameterValue() +67
System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +255
System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +265
System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +214
System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +68
System.Web.UI.WebControls.FormView.HandleInsert(String commandArg, Boolean causesValidation) +389
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +609
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +155
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921
I have verified that Label1.Text has a value that looks like an integer. What is causing the problem? Is there a better way of creating a new record in the child table and making one of the fields match the primary key of the parent table?
Thanks.
View 7 Replies
View Related
Nov 15, 2007
Hi!I get this message: System.FormatException: Input string was not in a correct format.
when i try to execute this code:
TextBox tbox = new TextBox();
string Date;
string Title;
string Text;
string sUserName = HttpContext.Current.User.Identity.Name;
MembershipUser User = Membership.GetUser(sUserName);
string UserID = User.ProviderUserKey.ToString();
int NewsID = Convert.ToInt32(ViewEditNews.DataKeys[e.Item.ItemIndex]);
tbox = (TextBox)e.Item.FindControl("EditNewsDateTxt");
Date = tbox.Text;
tbox = (TextBox)e.Item.FindControl("EditNewsTitleTxt");
Title = tbox.Text;
tbox = (TextBox)e.Item.FindControl("EditNewsTextTxt");
Text = tbox.Text;
GetNews.UpdateCommandType = SqlDataSourceCommandType.Text;
GetNews.UpdateCommand = "UPDATE ovarvet.News SET HeadText=@Title, Text=@Text, Date=@Date, UserID=@UserID WHERE NewsID=@NewsID";
GetNews.UpdateParameters.Add("Title",TypeCode.String, Title);
GetNews.UpdateParameters.Add("Text", TypeCode.String, Text);
GetNews.UpdateParameters.Add("Date", TypeCode.String, Date);
GetNews.UpdateParameters.Add("UserID", TypeCode.UInt32, UserID);
GetNews.UpdateParameters.Add("NewsID", TypeCode.Int32, NewsID.ToString());
GetNews.Update();
ViewEditNews.DataBind();
ViewEditNews.EditItemIndex = -1;
ViewEditNews.DataBind(); Anyone who knows the problem with this code?
View 7 Replies
View Related
Mar 20, 2008
Hello, this is my code and the problem is "Input string was not in a correct format."
Dim connection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("cnn"))
Dim percentage, jaar, kpi3, maand1 As IntegerDim cmd As SqlCommand = New SqlCommand
connection.Open()
percentage = CInt(TextBox1.Text)
jaar = CInt(TextBox2.Text)kpi3 = CInt(Kpi.SelectedValue)maand1 = CInt(Maand.SelectedValue)
cmd.CommandText = "INSERT INTO tblOverzicht(kpiID, maandID, jaar, percentage)values('" + CInt(kpi3) + "', '" + CInt(maand1) + "', '" + CInt(jaar) + "', '" + CInt(percentage) + "')"
cmd.ExecuteNonQuery()
connection.Close()
End Sub
View 10 Replies
View Related
Mar 28, 2008
Hi i keep getting an error when i search based on the coachname textbox or the team name dropdown list, when I search based on the region dropdown list it works fine. The error i get is "Input string was not in a correct format"
Here is my code;
protected void Button1_Click(object sender, EventArgs e)
{
if (this.IsValid)
{
lblResults.Text = "Here are the search results!";
}
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["streamConnectionString"].ConnectionString);
conn.Open();
SqlCommand command = new SqlCommand("stream_FindTeam", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@coachName", SqlDbType.VarChar, 250).Value = coachName.Text;command.Parameters.Add("@TeamName", SqlDbType.VarChar, 250).Value = TeamList.SelectedValue;
{
if ((string.IsNullOrEmpty(Region.SelectedValue)))
{
command.Parameters.Add("@regionID", DBNull.Value);
}
else
{
command.Parameters.Add("@regionID", SqlDbType.Int ).Value = Region.SelectedValue;
}
}
SqlDataReader reader = command.ExecuteReader();
DataList1.DataSource = reader;
DataList1.DataBind();
conn.Close();
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = !(String.IsNullOrEmpty(coachName.Text) && TeamList.SelectedIndex == 0 && Region.SelectedIndex == 0);
}
}
And my stored procedure is ALTER PROCEDURE [dbo].[stream_FindTeam]
@coachName varchar(100),
@TeamName varchar(100),
@regionID INT
AS
SELECT TeamID, coachName FROM Teams
WHERE coachName LIKE COALESCE(@coachName, coachName)
AND TeamName = COALESCE(@TeamName, TeamName)
AND regionID = COALESCE(@regionID, regionID);
View 2 Replies
View Related
Mar 30, 2008
Hi, im using vb,net sql 2005. I keep getting this error when inserting on one of my forms, normally i debug and have no probs solving this sort of thing but the error below isnt giving me anything to work on, could someone point me in the right direction. Any help would be appreciatedThanks
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2752899
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
System.String.System.IConvertible.ToInt32(IFormatProvider provider) +43
System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +293
System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +248
System.Web.UI.WebControls.ObjectDataSourceView.MergeDictionaries(ParameterCollection reference, IDictionary source, IDictionary destination, String parameterNameFormatString) +445
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteInsert(IDictionary values) +620
System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +68
System.Web.UI.WebControls.DetailsView.HandleInsert(String commandArg, Boolean causesValidation) +392
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +609
System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +155
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4925
View 1 Replies
View Related
Apr 13, 2008
Hi,I am trying to Update using SqlDataSource.I get the error: Input string was not in a correct format. Does anyone know what would cause this?Thanks,Jon
View 1 Replies
View Related
Jun 11, 2008
Hi i hope someone can help with my problem, im quite nb to asp.net. while im trying to update or insert the record i encountered the this error Input string was not in a correct format. I only encounter this only in one field (value_char9) pls note this is varchar2 in the table. the problem encounter when i try to input value greater than sign e.g. >1000, but if there no symbol updating and insertion work fine. If PageMode = "Add" ThencmdSql = New OleDbCommand("Select id From r_feclas Where fec_key='" & strFType & "' And fec_type='PNTTYP' And code_status<>'I'", sqlConn)intKPTId = cmdSql.ExecuteScalar()'cmdSql = New OleDbCommand("Select mond.Nextval From dual", sqlConn) : intId = cmdSql.ExecuteScalar()Dim cmdSql2 As OleDbCommand = New OleDbCommand()Dim sqlTrans As OleDbTransaction = sqlConn.BeginTransaction()cmdSql2.Connection = sqlConn : cmdSql2.Transaction = sqlTransTry 'cmdSql2.CommandText = "Select last_doc_num From r_docnum Where doc_type='MOND' FOR UPDATE" 'intId = cmdSql2.ExecuteScalar() + 1 'cmdSql2.CommandText = "Update r_docnum Set last_doc_num=" & intId & " Where doc_type='MOND'" cmdSql2.CommandText = "Select Mond.NextVal From dual" intId = cmdSql2.ExecuteScalar()sqlTrans.Commit()Catch ex As ExceptionsqlTrans.Rollback()lblErrorMsg.Text = ex.Message : lblErrorMsg.Visible = TrueReturnEnd TrystrSql = "Insert Into r_mondat (read_date, value_num1, value_char1, value_char2, value_char3, value_char4, value_char5, " & _ "value_char6, value_char7, value_char8, value_char9, value_char10, value_char11, value_char12, " & _ "value_char13, value_char14, value_char15, value_char16, value_char17, value_char18, value_char19, Id, " & _ "last_updt, updt_user, created_on, created_by, tag, position, key_pnt, tag_fe_id, positn_fe_id, keypnt_fe_id, " & _ "key_pnt_type_grp, key_pnt_type, form_type, key_pnt_type_id) " & _ "Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'" & Cache(Session.SessionID & "_UserId") & "',SYSDATE,'" & Cache(Session.SessionID & "_UserId") & "'," & _ "'" & strT & "','" & strP & "','" & strK & "'," & intT & "," & intP & "," & intK & ",'" & strFType & "','" & strFType & "','" & strFType & "'," & intKPTId & ")"ElseintId = dgrdData.DataKeys(0) strSql = "Update r_mondat Set read_date=?, value_num1=?, value_char1=?, value_char2=?, value_char3=?, value_char4=?, value_char5=?, " & _ "value_char6=?, value_char7=?, value_char8=?, value_char9=?, value_char10=?, value_char11=?, value_char12=?, " & _ "value_char13=?, value_char14=?, value_char15=?, value_char16=?, value_char17=?, value_char18=?, value_char19=?, " & _ "last_updt=sysdate " & "Where id=?" End If cmdSql = New OleDbCommand(strSql, sqlConn) cmdSql.Parameters.Add("@R1", OleDbType.Date).Value = dtDate cmdSql.Parameters.Add("@N1", OleDbType.Numeric).Value = GetValueFromDataGrid("N1") For i = 1 To 19 cmdSql.Parameters.Add("@C" & i, OleDbType.VarChar, 20).Value() = GetValueFromDataGrid("C" & i) Next cmdSql.Parameters.Add("@Id", OleDbType.Numeric).Value = intId Try cmdSql.ExecuteNonQuery() lblErrorMsg.Text = "Data Updated Successfully." dgrdData.EditItemIndex = -1 If PageMode = "Add" Then RetrieveLeakData(intId) Else RetrieveLeakData() Catch ex As Exception lblErrorMsg.Text = ex.Message Finally sqlConn.Close() End Try lblErrorMsg.Visible = True Trace.Write("lnkUpdate_Click End")
View 6 Replies
View Related
Jun 11, 2008
I have the information below
PRINT REPLACE(REPLACE(CONVERT(varchar(50), GetDate()), ' ', ''), ':', '')
What I would Like to do is run the query above and get date of this type '2003-05-08 12:35:29.998' returned as '20030508123529998'
I know GetDate does not even come up with date in the first format so I need to know which way to get it in the first format so that I can run the query and get the second format string returned to me. Thanks in Advance
View 4 Replies
View Related
Sep 24, 2004
************* Edited by moderator Adec ***************
Inserted missing < code></ code> tags. Always include such
tags when including code in your postings. Don't force the
moderators to do this for you. Many readers disregard
postings without the code tags.
**************************************************
I've been workin on this a while and hope I just missed something simple. I have a login page that looks in the db for the rec_id that has the correct un/pw combo. Simple u'd think but I keep getting that error. Any help is greatly appreciated.
Private Sub CheckUser(ByVal CurrentSQLCommand As SqlCommand)
'Declare vars for user and pass. Not needed now but will be used for input checking later
Dim strUN As String = txtUN.Text
Dim strPW As String = txtPW.Text
CurrentSQLCommand.Parameters.Item("@un").Value = strUN
CurrentSQLCommand.Parameters.Item("@pw").Value = strPW
SqlConnection1.Open()
Dim datareader As SqlDataReader = CurrentSQLCommand.ExecuteReader
While datareader.Read
If datareader.HasRows Then
txtID.Text = datareader(0)
If txtR.Text = 3 Then
Response.Redirect("hcprov.aspx?id=" & txtID.Text)
ElseIf txtR.Text = 2 Then
Response.Redirect("hcprof.aspx?id=" & txtID.Text)
ElseIf txtR.Text = 1 Then
Response.Redirect("hca.aspx?id=" & txtID.Text)
End If
'CreateTicket()
ElseIf Not datareader.HasRows Then
txtUN.Text = ""
txtPW.Text = ""
lblError.Text = "This User/Pass combo is not valid please try again!"
lblError.Visible = True
End If
datareader.Close()
SqlConnection1.Close()
End While
End Sub
cmdCheckProfUser
SELECT REC_ID
FROM dbo.HCPROFESSIONAL
WHERE (UN = @un) AND (PW = @pw)
View 7 Replies
View Related
Apr 14, 2005
Hi all,
Complete newbie to ASP.NET, but you have to learn some time. Anyway, I am attempting to fill a datagrid from the Northwind database installed on my SQL server at work and I receive the following error when I attempt to compile to check the connection.
Format of the initialization string does not conform to specification starting at index 67.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 67.Source Error:
Line 31:
Line 32: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Line 33: Dim cnn As New SqlConnection( _
Line 34: "Data source=xxxxx;Initial Catalog=Northwind;User ID=sa;Password=;xxxxxx")
Line 35: End SubSource File: C:InetpubwwwrootApp_02default.aspx.vb Line: 33 Stack Trace:
[ArgumentException: Format of the initialization string does not conform to specification starting at index 67.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, String& keyname, String& keyvalue) +1203
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +127
System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useFirstKeyValuePair) +103
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +32
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +25
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolOptions poolOptions, DbConnectionOptions& userConnectionOptions) +119
System.Data.ProviderBase.DbConnectionBase.set_ConnectionString(String value) +53
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +7
System.Data.SqlClient.SqlConnection..ctor(String connectionString) +23
App_02.WebForm1.Page_Load(Object sender, EventArgs e) in C:InetpubwwwrootApp_02default.aspx.vb:33
System.Web.UI.Control.OnLoad(EventArgs e) +102
System.Web.UI.Control.LoadRecursive() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +952
I have been tearing my hair out trying to work out this error. Can anyone help????
Using VisualStudio.NET 2003 on an XP box and and SQL Server 2000 on a Windows2003 Server box.
Thanks,
Gerald
View 1 Replies
View Related
May 16, 2005
Looking for some help with a page that is giving me problems. Below is code for the function that I need help with:
Function MyInsertMethod() As Integer Dim connectionString As String = "server=chatt; user id='sa'; password=1234; database=chtt_Fit"& _ "tings'" Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "INSERT INTO [ProcessYield] ([ProdDate], [CupolaCharge], [MetalPoured], [ToTen],[FeSiCharge],lt1,lt2,lt3,lt4) VALUES (@ProdDate, @CupolaCharge, @MetalPoured, @ToTen, @FeSiCharge,@lt1,@lt2,@lt3,@lt4)" Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection
Dim ProdDate as String = Calendar1.selecteddate Dim ParameterProdDate as New SqlParameter("@ProdDate",SqldbType.datetime, 8) ParameterProdDate.Value = ProdDate dbCommand.Parameters.Add(ParameterProdDate)
Dim MetalPoured as String = TextBox3.Text Dim ParameterMetalPoured as New SqlParameter("@MetalPoured",SqldbType.float, 8) ParameterMetalPoured.Value = MetalPoured dbCommand.Parameters.Add(ParameterMetalPoured)
Dim CupolaCharge as String = Textbox1.Text Dim ParameterCupolaCharge as New SqlParameter("@CupolaCharge",SqldbType.float, 8) ParameterCupolaCharge.Value = CupolaCharge dbCommand.Parameters.Add(ParameterCupolaCharge)
Dim ToTen as String = Textbox4.Text Dim ParameterToTen as New SqlParameter("@ToTen",SqldbType.float, 8) ParameterToTen.Value = ToTen dbCommand.Parameters.Add(ParameterToTen)
Dim FeSiCharge as string = (Textbox5.Text/2000) Dim ParameterFeSiCharge as New SqlParameter("@FeSiCharge",SqldbType.float, 8) ParameterFeSiCharge.Value = FeSiCharge dbCommand.Parameters.Add(ParameterFeSiCharge)
Dim lt1 as String = TextBox6.Text Dim Parameterlt1 as New SqlParameter("@lt1",SqldbType.float, 8) Parameterlt1.Value = lt1 dbCommand.Parameters.Add(Parameterlt1)
Dim lt2 as String = TextBox7.Text Dim Parameterlt2 as New SqlParameter("@lt2",SqldbType.float, 8) Parameterlt2.Value = lt2 dbCommand.Parameters.Add(Parameterlt2)
Dim lt3 as String = TextBox8.Text Dim Parameterlt3 as New SqlParameter("@lt3",SqldbType.float, 8) Parameterlt3.Value = lt3 dbCommand.Parameters.Add(Parameterlt3)
Dim lt4 as String = TextBox9.Text Dim Parameterlt4 as New SqlParameter("@lt4",SqldbType.float, 8) Parameterlt4.Value = lt4 dbCommand.Parameters.Add(Parameterlt4)
Dim rowsAffected As Integer = 0 dbConnection.Open
Try rowsAffected = dbCommand.ExecuteNonQuery Finally dbConnection.Close End Try Return rowsAffected End Function
Ok the error happens when a user leaves the textbox5.text empty...pages says not to enter 0 since you can't divide into zero. This page has worked for over a year but recently upgraded from SQL 7.0 to SQL 2000 and is no longer working.
Have tried converting data types, different data types on server, etc. Any advise is appreciated. Thanks. BTW new to forums... if this is wrong board to post on sorry and feel free to move where needed.
Here is submit code if that helps any also:
Sub Button2_Click(sender As Object, e As EventArgs) MyInsertMethod() UpdateDailyActivity() MXDataGrid1.DataSource = Getsaveresult() MXDataGrid1.DataBind() textbox1.text = "" textbox3.text = "" textbox4.text = "" textbox5.text = "" textbox6.text = "0" textbox7.text = "0" textbox8.text = "0" textbox9.text = "0"
Error Message:
FormatException: Input string was not in a correct format.] Microsoft.VisualBasic.CompilerServices.DoubleType.Parse(String Value, NumberFormatInfo NumberFormat) +195 Microsoft.VisualBasic.CompilerServices.DoubleType.FromString(String Value, NumberFormatInfo NumberFormat) +84[InvalidCastException: Cast from string "" to type 'Double' is not valid.] Microsoft.VisualBasic.CompilerServices.DoubleType.FromString(String Value, NumberFormatInfo NumberFormat) +173 Microsoft.VisualBasic.CompilerServices.DoubleType.FromString(String Value) +7 ASP.CupolaYieldEntry_aspx.MyInsertMethod() in D:ProductionControlyieldcupolayieldentry.aspx:76 ASP.CupolaYieldEntry_aspx.Button2_Click(Object sender, EventArgs e) in D:ProductionControlyieldcupolayieldentry.aspx:142 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292
View 1 Replies
View Related
Aug 17, 2005
Can anybody point me to a list of all valid string formats for passing in datetime variables into SQL server. Ideally I just want to put in a date and not bother with a time
View 3 Replies
View Related
Nov 5, 2005
I am trying to do an insert into a SQL server table but I am getting an "input string was not in correct format" error. Does this error always refer to SQL string problem? I put in a breakpoint and looked at the SQL and it looks good but until I figure this out I will be tracing through the code. Any input greatly appreciated. MyCmd.CommandText = sSQL MyCmd.ExecuteNonQuery() 'Line where I get the errorThanks,Joe
View 2 Replies
View Related
Apr 3, 2006
Hi,
I am trying to insert a record into 2 tables with master-child relationship. When i execute the code i get this error on the statement " UserID = Convert.ToInt32(cmdExp.ExecuteScalar())"
Can anyone help?
CODE AS FOLLOWS
Dim con As SqlConnection
Dim trans As SqlTransaction = Nothing
Dim cmdExp As SqlCommand
Try
con = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
con.Open()
trans = con.BeginTransaction
'CREATE THE COMMAND
cmdExp = New SqlCommand()
cmdExp.Connection = con
cmdExp.Transaction = trans
'Create the appropriate SQL statement
cmdExp.CommandText = "INSERT INTO USER_DETAILS (HOSPITAL_ID,FIRST_NAME,LAST_NAME,ADDRESS,CITY,STATE,ZIP,PHONE,EMAIL,REG_CODE,STATUS,REG_DATE,UPDATE_DATE) VALUES (@PARHOSPITALID,@PARFIRSTNAME,@PARLASTNAME,@PARADDRESS,@PARCITY,@PARSTATE,@PARZIP,@PARPHONE,@PAREMAIL,@PARREGCODE,@PARSTATUS,@PARREGDATE,@PARUPDATEDATE)"
'Add the parameters
cmdExp.Parameters.Add(New SqlParameter("@PARHOSPITALID", SqlDbType.Int, 4))
cmdExp.Parameters("@PARHOSPITALID").Value = var_hospitalid
cmdExp.Parameters.Add(New SqlParameter("@PARFIRSTNAME", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARFIRSTNAME").Value = var_firstname
cmdExp.Parameters.Add(New SqlParameter("@PARLASTNAME", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARLASTNAME").Value = var_lastname
cmdExp.Parameters.Add(New SqlParameter("@PARADDRESS", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARADDRESS").Value = var_address
cmdExp.Parameters.Add(New SqlParameter("@PARCITY", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARCITY").Value = var_city
cmdExp.Parameters.Add(New SqlParameter("@PARSTATE", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARSTATE").Value = var_state
cmdExp.Parameters.Add(New SqlParameter("@PARZIP", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARZIP").Value = var_zip
cmdExp.Parameters.Add(New SqlParameter("@PARPHONE", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARPHONE").Value = var_phone
cmdExp.Parameters.Add(New SqlParameter("@PAREMAIL", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PAREMAIL").Value = var_email
cmdExp.Parameters.Add(New SqlParameter("@PARREGCODE", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARREGCODE").Value = var_regcode
cmdExp.Parameters.Add(New SqlParameter("@PARSTATUS", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARSTATUS").Value = var_status
cmdExp.Parameters.Add(New SqlParameter("@PARREGDATE", SqlDbType.DateTime, 8))
cmdExp.Parameters("@PARREGDATE").Value = DateTime.Now()
cmdExp.Parameters.Add(New SqlParameter("@PARUPDATEDATE", SqlDbType.DateTime, 8))
cmdExp.Parameters("@PARUPDATEDATE").Value = DateTime.Now()
Dim UserID As Integer
UserID = Convert.ToInt32(cmdExp.ExecuteScalar())
cmdExp.CommandText = "UPDATE WEBCAM SET USER_ID= @PARUSERID,STATUS =@PARWEBCAMSTATUS WHERE WEBCAM_ID='" & var_webcamid & "'"
cmdExp.Parameters.Add(New SqlParameter("@PARUSERID", SqlDbType.BigInt, 8))
cmdExp.Parameters("@PARUSERID").Value = UserID
cmdExp.Parameters.Add(New SqlParameter("@PARWEBCAMSTATUS", SqlDbType.VarChar, 20))
cmdExp.Parameters("@PARWEBCAMSTATUS").Value = "INUSE"
cmdExp.ExecuteNonQuery()
trans.Commit()
View 4 Replies
View Related
May 7, 2008
I'm new here so I'm not sure if this is the correct spot to post this question but here goes.
In the cube design view under the Calculations tab I have several calculated members that I have created. Each of these are dollar amount fields for which I have defined a Format String property as follows:
Format String: "$#,##0;($#,##0);;N/A"
This format correctly handles my positive value, Negative value and my NULL value the way I want. However I need to deloy this cube on one of my UK severs and I don't want the $ but instead I would like the pound sign without having to recreate this entire project to do so. I have tried the following syntax but it is incorrect.
Format String "Currency;;;N/A"
Can someone help me with the correct way to code the property so that I can get my currecy symbol based on the regional setting as well as handle my NULL values.
Thanks
View 1 Replies
View Related
Jun 12, 2008
I am trying to import a txt file that has a string for it's date. How do I change it over in the import wizard I've tried going to advance then changing from string to date or date time but I get an error.
View 14 Replies
View Related
Sep 12, 2007
hi,
i have a problem.
i m inserting data in "dd/mm/yyyy" string format and i want to ocnvert in "dd mon yyyy" format.
for eg-- i m entering 30/11/2007" and i wnat in this format "30 Nov 2007"
if any body knows please help me.
thanx...
View 12 Replies
View Related
Sep 22, 2005
Hi. I have data which comes as a string like"... Store #61"but sometimes it is"... Store 61"and sometimes it is"... Store 061"For three digits, it might be "... Store 561" or "... Store #561", or"... Store 0561".....The only thing I can be sure of is that the last 2 or 3 (significant)digits of this field represent the StoreNumber.I have to link this table on field StoreNumber with another table wherethe data is ALWAYS like 0061, 0561, etc, so always four digits, paddedwith zeroes.I'd like to use the equivalent of the VB functionFormat(StoreNumber), "0000"), but Format does NOT exist in TSQL.How could I solve this problem ? Please bear with me - I'm a beginnerin SQL...Thank you very muchAlex.
View 5 Replies
View Related
Feb 22, 2007
Ok my last formatting question.How can I insert a money value as a padded string in another table?example $1.25 gets inserted to another table as 00000125I want 8 total characters and no decimalanother example would be 4,225.99 becomes 00422599can this be done?thank you!!
View 7 Replies
View Related
Jul 20, 2005
Hi,I have a funny Error in our sql server 7 & 2000. When I compare twostring in Unicode format. I receive that it is the same when I add newnchar.I don’t understand why?Could you help me ?declare @str nvarchar(128), @str2 nvarchar(128)Set @str =nchar(21121)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25736)+nchar(1788)+nchar(51220)+nchar(17733)Set @str2 =nchar(21121)+nchar(49352)+nchar(47811)+nchar(48256 )+nchar(4966)+nchar(25736)+nchar(1788)+nchar(51220)+nchar(17733)+nchar(4 1273)select @strselect @str2SELECT DIFFERENCE(@str, @str2)if soundex(@str) = soundex(@str2)BEGINSELECT 'OK'ENDELSEBEGINSELECT 'KO'ENDif @str = @str2BEGINSELECT 'OK'ENDELSEBEGINSELECT 'KO'END-=zoltux=-*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 1 Replies
View Related
Jul 20, 2005
im using asp.net, C# to enter data into a table in sqlserver...however im getting this error:Input string was not in a correct format.Description: An unhandled exception occurred during the execution ofthe current web request. Please review the stack trace for moreinformation about the error and where it originated in the code.Exception Details: System.FormatException: Input string was not in acorrect format.Source Error:Line 120:cmd.Parameters.Add("@commission",SqlDbType.Money);Line 121:cmd.Parameters["@commission"].Direction=ParameterDirection.Input;Line 122:cmd.Parameters["@commission"].Value =Convert.ToDouble(txtinvoice.Text);Line 123:cmd.Parameters.Add("@pricesold",SqlDbType.Money);Line 124:cmd.Parameters["@pricesold"].Direction=ParameterDirectionSimilar error messages appear when I leave text fields blank that aregoing to be inserted into fields in the table of datatype money,datetime or int...however when i execute this in query analyzer it works and inputs nullvalues for those fields:declare @empid varchar(20), @inventoryid int, @clientid int,@commission money,@pricesold money, @datesold datetime, @invoiceidint, @shippingcost money, @terms varchar(50), @details varchar(50),@clienttype smallint, @checker int, @errordesc varchar(100)set @empid = 'admin'set @inventoryid = 14set @clientid= 2set @clienttype = 0set @commission = nullexec STP_updateconsignment @empid, @inventoryid, @clientid,@commission,@pricesold, @datesold, @invoiceid, @shippingcost, @terms,@details, @clienttype, @checker output, @errordesc outputIf Im in enterprise manager and try to enter a blank value into one ofthose fields I get: The value you entered is not consistent with thedata type or length of the column...so im wondering if the C# page issending my stored procedure a blank value instead of a Null andcausing this error?any advice would be nice..thanks-Jim
View 2 Replies
View Related