Format Of The Initialization String Does Not Conform To The OLE DB Specification.
Feb 5, 2008
In Server Explorer I am trying to add a data connection for OUR database using OUR own ole db data provider. Procedure below-
1. Right click "Data Connections"
2. Click "Add Connection...", "Change Data Source" dialog is displayed.
3. Select "other" and ".NET Framework Data Provider for OLE DB". Click OK. "Add Connection" dialog is displayed.
4. Select "OLE DB Provider". I selected OUR provider.
5. Edit necessary properties. Click OK.
6. An error dialog is displayed saying "Format of the initialization string does not conform to the OLE DB specification."
If I go back to the "Add Connection" dialog(after clicking OK on error) and click "Advanced", I see connection string as--
Provider=OURPROVIDER;Data Source=our_backend;Password=password;User ID=admin;Initial Catalog=mydb
I am not able to find out what/where went wrong. I tried this conneciton string in a c# program, it works perfectly fine.
Can anyone help me on why I am getting this error with our provider in SSIS?
Thanks,
Vivek.
View 3 Replies
ADVERTISEMENT
Feb 11, 2008
It is SQL Server 2005. I am trying to create an SSIS package for OUR database engine with OUR OLE DB provider.
In Server Explorer I am trying to add a data connection for OUR database using OUR own ole db data provider. Procedure below-
1. Right click "Data Connections"
2. Click "Add Connection...", "Change Data Source" dialog is displayed.
3. Select "other" and ".NET Framework Data Provider for OLE DB". Click OK. "Add Connection" dialog is displayed.
4. Select "OLE DB Provider". I selected OUR provider.
5. Edit necessary properties. Click OK.
6. An error dialog is displayed saying "Format of the initialization string does not conform to the OLE DB specification."
I did some tracing. My observations are-
Connection string is built internally as
"Provider=MYOLEDB;Password=password;Data Source=myserver;User ID=admin;Initial Catalog=SYSTEM;Window Handle=984398;Prompt=CompleteRequired"
The last property causes this issue. i.e. presence of 'Prompt=CompleteRequired' is the problem.
I tried this with simple c# test program to connect. If I pass the whole connection string as above to OleDbConnection() it gives the error--
"Format of the initialization string does not conform to the OLE DB specification."
It works fine if I pass connection string removing last property, i.e.
"Provider=MYOLEDB;Password=password;Data Source=myserver;User ID=admin;Initial Catalog=SYSTEM;Window Handle=984398"
So the problem is that the connection string built contains 'Prompt=CompleteRequired' at the end. Our provider returns DBPROMPT_NOPROMPT for DBPROP_INIT_PROMPT property. Still why the connection string is built as 'Prompt=CompleteRequired'?
Probably this is because of missing something in properties/implementation. What is it?
Thanks,
Vivek.
View 4 Replies
View Related
Apr 18, 2007
can't figure out this error. i think i'm writing something wrong in the connnection string. i'm using SQL Server Express, if that helps. in my config file: <connectionStrings> <add name="OfficialScribblerConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|OfficialScribbler.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </connectionStrings> in my aspx file:Dim DBConnection = New OleDbConnection("OfficialScribblerConnectionString") DBConnection.Open() Dim SQLString As String = "SELECT PostedDate From Entries_tbl ORDER BY PostedDate"
View 5 Replies
View Related
Jun 6, 2007
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 0.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: [ArgumentException: Format of the initialization string does not conform to specification starting at index 0.] System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +1242 System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +128 System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +102 System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +52 System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24 System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +125 System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +56 System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +138 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70 System.Web.UI.WebControls.GridView.DataBind() +4 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69 System.Web.UI.Control.EnsureChildControls() +87 System.Web.UI.Control.PreRenderRecursiveInternal() +41 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
View 2 Replies
View Related
Feb 4, 2008
I received this error my server:
[ArgumentException: Format of the initialization string does not conform to specification starting at index 0.] System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +1242 System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +128 System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +102 System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +52 System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24 System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +125 System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +56 System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4 System.Data.SqlClient.SqlConnection..ctor(String connectionString) +21 admin_ratings.Page_Load(Object sender, EventArgs e) +1345 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
Here's my code, and this worked fine with the 3rd connection string on my local machine. It did the update to the proper fields in my db:
Dim Original_WebsiteID As Integer = tblwebsiteRow.WebSiteID Dim conRatings As SqlConnection
Dim strUpdate As StringDim cmdUpdate As SqlCommand conRatings = New SqlConnection(ConnectionString = "Connect Timeout=8; Integrated Security=True;Database=linkexchanger; Server=************;uid=****; pwd=********; ")
'conRatings = New SqlConnection(ConnectionString = "Connect Timeout=8; Initial Catalog=linkexchanger; Data Source=******; uid=*****; pwd=*****;")
'conRatings = New SqlConnection("Server=SCOTSQLEXPRESS;Initial Catalog=linkexchanger;Integrated Security=True;Connect Timeout=8;")
strUpdate = "UPDATE tblWebSite SET Rating = " & Rate & "WHERE (WebSiteID = " & Original_WebsiteID & ")"cmdUpdate = New SqlCommand(strUpdate, conRatings)
conRatings.Open()
cmdUpdate.ExecuteNonQuery()
conRatings.Close()
Next
End Sub
View 10 Replies
View Related
Jan 24, 2004
I'm trying to build a connection string to SQL Server 7.0 from ASP.net w/ C#
I get the following error:
Format of the initialization string does not conform to the OLE DB specification. Starting around char[100] in the connection string.
What the heck does this mean? What am I doing wrong.. My connection string is below:
string strConnection = "Provider='Provider=SQLOLEDB; server=XXXXXX.XXXXXXXXXXXXX.COM;'UID=XXXXXX;PWD=XXXXXXX;DATABASE=XXXXXX'";
Is there a way to make good connection strings like a tool or something?
Thanks for your time.
thunk
View 2 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
Jul 3, 2007
I am trying to get the CLR user-defined aggregate functions sample working (VB version).
I've saved the sample (from Invoking CLR User-Defined Aggregate Functions ) to a .vb file and compiled it like this:
C:dataVStudioprojectsSQLutilsSQLutils>c:WINDOWSMicrosoft.NETFrameworkv2
.0.50727vbc /t:library /out: SQLutils.dll Class1.vb
Microsoft (R) Visual Basic Compiler versie 8.0.50727.42
voor Microsoft (R) .NET Framework versie 2.0.50727.42
Copyright (c) Microsoft Corporation. Alle rechten voorbehouden.
The SQLutils.dll file is created without warnings or errors.
I've created the assembly
create assembly sqlutildll from 'D:SQLdatadllSQLutils.dll'
and then the function:
CREATE AGGREGATE Concat (@input nvarchar(200)) RETURNS nvarchar(max)
EXTERNAL NAME sqlutildll.Concatenate
and then I got this error:
Msg 6558, Level 16, State 1, Line 1
CREATE AGGREGATE failed because type 'Concatenate' does not conform to UDAGG specification due to method 'Init'.
Msg 6597, Level 16, State 2, Line 1
CREATE AGGREGATE failed.
What is this UDAGG specification ?
How can I make this function working?
The VB code:
Code Snippet
Imports System
Imports System.Data
Imports Microsoft.SqlServer.Server
Imports System.Data.SqlTypes
Imports System.IO
Imports System.Text
<Serializable(), SqlUserDefinedAggregate(Format.UserDefined, IsInvariantToNulls:=True, IsInvariantToDuplicates:=False, IsInvariantToOrder:=False, MaxByteSize:=8000)> <Microsoft.VisualBasic.ComClass()> _
Public Class Concatenate
Implements IBinarySerialize
''' <summary>
''' The variable that holds the intermediate result of the concatenation
''' </summary>
Private intermediateResult As StringBuilder
''' <summary>
''' Initialize the internal data structures
''' </summary>
Public Sub Init()
Me.intermediateResult = New StringBuilder()
End Sub
''' <summary>
''' Accumulate the next value, not if the value is null
''' </summary>
''' <param name="value"></param>
Public Sub Accumulate(ByVal value As SqlString)
If value.IsNull Then
Return
End If
Me.intermediateResult.Append(value.Value).Append(","c)
End Sub
''' <summary>
''' Merge the partially computed aggregate with this aggregate.
''' </summary>
''' <param name="other"></param>
Public Sub Merge(ByVal other As Concatenate)
Me.intermediateResult.Append(other.intermediateResult)
End Sub
''' <summary>
''' Called at the end of aggregation, to return the results of the aggregation.
''' </summary>
''' <returns></returns>
Public Function Terminate() As SqlString
Dim output As String = String.Empty
'delete the trailing comma, if any
If Not (Me.intermediateResult Is Nothing) AndAlso Me.intermediateResult.Length > 0 Then
output = Me.intermediateResult.ToString(0, Me.intermediateResult.Length - 1)
End If
Return New SqlString(output)
End Function
Public Sub Read(ByVal r As BinaryReader) Implements IBinarySerialize.Read
intermediateResult = New StringBuilder(r.ReadString())
End Sub
Public Sub Write(ByVal w As BinaryWriter) Implements IBinarySerialize.Write
w.Write(Me.intermediateResult.ToString())
End Sub
End Class
View 5 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
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
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
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