Hi experts, I am working on my asp.net application and received an error message on dr = cmdGetFile.ExecuteReader:Error: Input string was not in a correct format. Can someone help me out of this? Thank you in advance.------------------------------------------------------------------------------------ #Region " Web Form Designer Generated Code "
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.cmdGetFile = New System.Data.SqlClient.SqlCommand Me.dbHRConn = New System.Data.SqlClient.SqlConnection ' 'cmdGetFile ' Me.cmdGetFile.CommandText = "SELECT App_Resume_FileSize, App_Resume_FileName, App_Resume, App_Resume_FileType " & _ "FROM Mgmt_App_Resume_Table WHERE (Applicant_ID = @AppID)" Me.cmdGetFile.Connection = Me.dbHRConn Me.cmdGetFile.Parameters.Add(New System.Data.SqlClient.SqlParameter("@AppID", System.Data.SqlDbType.SmallInt, 2, "Applicant_ID")) ' 'dbHRConn ' Me.dbHRConn.ConnectionString = "the connection string"
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dr As System.Data.SqlClient.SqlDataReader cmdGetFile.Parameters("@AppID").Value = Request("Applicant_ID") dbHRConn.Open() dr = cmdGetFile.ExecuteReader
If dr.Read Then Response.ContentType = dr("App_Resume_FileType").ToString Response.OutputStream.Write(CType(dr("App_Resume"), _ Byte()), 0, CInt(dr("App_Resume_FileSize"))) Response.AddHeader("Content-Disposition", _ "attachment;filename=" + dr("App_Resume_FileName").ToString()) Else Response.Write("File Not Found.") End IfEnd Sub
I have a page where user can insert a new record, i use stroed procedures:ALTER PROCEDURE [dbo].[sp_InsertTypes] @Type varchar(10), @Type_Desc varchar(35), @Contact_Name varchar(20), @Contact_Ad1 varchar(25), @Contact_Ad2 varchar(25), @Contact_City varchar(10), @Contact_Phone varchar(12), @Contact_Fax varchar(12), @Contact_Email varchar(35) Insert into dbo.Types (Type,Type_Desc,Contact_Name,Contact_Ad1,Contact_Ad2,Contact_City,Contact_Phone, Contact_Fax,Contact_Email) values (@Type,@Type_Desc,@Contact_Name,@Contact_Ad1,@Contact_Ad2,@Contact_City, @Contact_Phone, @Contact_Fax,@Contact_Email) My code is:Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)Dim myCommand As SqlCommand Dim TypeTxt As TextBox = FormView1.FindControl("TypeTextBox")Dim DescTxt As TextBox = FormView1.FindControl("TypeDescTextBox") Dim NameTxt As TextBox = FormView1.FindControl("ContactNameTextBox")Dim phoneTxt As TextBox = FormView1.FindControl("ContactPhoneTextBox") Dim ad1Txt As TextBox = FormView1.FindControl("ContactAd1Textbox")Dim ad2Txt As TextBox = FormView1.FindControl("ContactAd2Textbox") Dim cityTxt As TextBox = FormView1.FindControl("ContactCityTextbox")Dim faxTxt As TextBox = FormView1.FindControl("ContactFaxTextbox") Dim emailTxt As TextBox = FormView1.FindControl("ContactEmailTextbox")myCommand = New SqlCommand("[dbo].[sp_Insert_Types]", myConnection) myCommand.CommandType = CommandType.StoredProcedure myCommand.Parameters.Add("@Type", SqlDbType.BigInt).Value = TypeTxt.Text myCommand.Parameters.Add("@Type_Desc", SqlDbType.VarChar).Value = DescTxt.Text myCommand.Parameters.Add("@Contact_Name", SqlDbType.VarChar).Value = NameTxt.Text myCommand.Parameters.Add("@Contact_Phone", SqlDbType.VarChar).Value = phoneTxt.Text myCommand.Parameters.Add("@Contact_Ad1", SqlDbType.VarChar).Value = ad1Txt.Text myCommand.Parameters.Add("@Contact_Ad2", SqlDbType.VarChar).Value = ad2Txt.Text myCommand.Parameters.Add("@Contact_City", SqlDbType.VarChar).Value = cityTxt.Text myCommand.Parameters.Add("@Contact_Fax", SqlDbType.VarChar).Value = faxTxt.Text myCommand.Parameters.Add("@Contact_Email", SqlDbType.VarChar).Value = emailTxt.Text myConnection.Open() myCommand.ExecuteNonQuery() myConnection.Close() End Sub I have almost the identical procedure & code for Update command button, and worked well, what am I doing wrong? I even tried adding ' in front and after the texts. Thank you.
I am trying to execute an SQL update statement as follows:myObj.Query("Update Schedule Set visitorScore=" + t1 + ", homeScore=" + t2 + " where id=" + Convert.ToInt16(HID.Value));However, I'm getting the following error message with regards to this line.: Exception Details: System.FormatException: Input string was not in a correct format. Could anyone please tell me what is wrong with this line? I have tried many different versions of this, but keep getting the same error. THANKS IN ADVANCE!
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)
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:
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.
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;
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
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;
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);
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
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
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")
************* 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
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)
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
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
Code SnippetSQL: select max(id) from t1 Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Data.Odbc.OdbcDataReader.internalGetInt64(Int32 i) at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i, TypeMap typemap) at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i) at System.Data.Odbc.OdbcCommand.ExecuteScalar()
really strange error
this is the table t1 name varchar id bigint
select name from t1 works. select id from t1 gave me the same error as above too.
Is it because of its compatible with odbc connection for SQL Server 2005?
what is causing the problem?
Further updates!! select id from t1 works if data type is int instead of bigint !!! is this a problem with the SQL Server driver?
I'm connecting to the database via ODBC DSN by the way. OS is Windows Server 2003.
hi i have a database with some data in it and iam using full-text-search to search through my data and the search query works fine in sql server manamgnet studio. so my problem is in my web application, i have a textbox where i enter e.g car and click the search button, the button executes the search query but i recive an error "Input string was not in a correct format". here is the code that the button executes: Protected Sub searchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) searchSqlDataSource.SelectCommand = "Select ID, title, FROM myTable WHERE CONTAINS(description, @search)" searchSqlDataSource.SelectParameters.Add("search", searchTextBox.Text) searchSqlDataSource.DataBind() End Sub tnx in advac
Ok, when I bind a textbox in my FormView I'm changing the format to currency (<%# Bind("TotalValue","{0:c}") %>). When I click Update I get "Input string was not in a correct format" since TotalValue is Int32 data type.
Shouldn't it convert it back to Int32 when it updates the db? Or do I have to do it manually, and if so how?
I get this error : [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox34.Paragraphs[0].TextRuns[0]’ contains an error: Input string was not in a correct format.
When i put this Expression in new field that i called C:
I have 2 DropDownList, the first one to display the product category and the other one to display the products based on the selected category. However, when I run code I received the following error message: Input string was not in a correct format. Please find the code below. Thanks, Andy. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"><title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Name"> </asp:DropDownList>
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
I try to call the storeproc to perform task by allowing only input 6 of length. The syntax over here might not be relevant, im seeking for correct syntax. webform Dim connString2 As String = _ConfigurationManager.ConnectionStrings("Local_LAConnectionString1").ConnectionString Using myConnection2 As New SqlConnection(connString2) Dim test01 As IntegerDim myPuzzleCmd2 As New SqlCommand("GetRandomCode", myConnection2) myPuzzleCmd2.CommandType = CommandType.StoredProcedure Dim retLengthParam As New SqlParameter("@Length", SqlDbType.TinyInt, , 6) < -------- allow 6 letters in length to be input retLengthParam.Direction = ParameterDirection.InputmyPuzzleCmd2.Parameters.Add(retLengthParam) Dim retRandomCode As New SqlParameter("@RandomCode", SqlDbType.VarChar, 30) retRandomCode.Direction = ParameterDirection.Output myPuzzleCmd2.Parameters.Add(retRandomCode) TryDim reader2 As SqlDataReader = myPuzzleCmd2.ExecuteReader() myPuzzleCmd2.ExecuteNonQuery() Catch ex As Exception Response.Write("sp value : " & retRandomCode.Value) Dim iRandomCode(1) As StringReDim Preserve iRandomCode(1) iRandomCode(1) = Convert.ToString(retRandomCode.Value)myPuzzleCmd2 = Nothing Session.Remove("RandomCode") HttpContext.Current.Session("RandomCode") = iRandomCode(1) Response.Write(Session("RandomCode")) Finally myConnection2.Close() End Try End Using
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
Hi, I am trying to do a simple ftp using DTS. I am using a Dynamic properties task as the file name is a bit complicated eg - f2368fd1.ext.040330.2 where 040330 is according to the date and the .2 is the second file for the day. When i run the task, it fails giving me the error "Invalid format for string source names"
I then tried to use a simple file name such as TD.txt as a constant in the Dynamic properties task but still it fails. Any ideas ??
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?
I have a scenario where in I need to use a comma delimited string as input. And search the tables with each and every string in the comma delimited string.
Hi, How does one generate a date string from a DateTime object which is formatted in the correct way for the database? I want to avoid the possibility of getting the month and the day the wrong way around. Cheers, WT.
I have a nasty situation in SQL Server 7.0. I have a table, in whichone column contains a string-delimited list of IDs pointing to anothertable, called "Ratings" (Ratings is small, containing less than tenvalues, but is subject to change.) For example:[ratingID/descr]1/Bronze2/Silver3/Gold4/PlatinumWhen I record rows in my table, they look something like this:[uniqueid/ratingIDs/etc...]1/2, 4/...2/null/...3/1, 2, 3/...My dilemma is that I can't efficiently read rows in my table, match thestring of ratingIDs with the values in the Ratings table, and returnthat in a reasonable fashion to my jsp. My current stored proceduredoes the following:1) Query my table with the specified criteria, returning ratingIDs as acolumn2) Split the tokens in ratingIDs into a table3) Join this small table with the Ratings table4) Use a CURSOR to iterate through the rows and append it to a string5) Return the string.My query then returns...1/"Silver, Platinum"2/""3/"Bronze, Silver, Gold"And is easy to output.This is super SLOW! Queries on ~100 rows that took <1 sec now take 12secs. Should I:a) Create a junction table to store the IDs initially (I didn't thinkthis would be necessary because the Ratings table has so few values)b) Create a stored procedure that does a "SELECT * FROM Ratings," putthe ratings in a hashtable/map, and match the values up in Java, sinceJava is better for string manipulation?c) Search for alternate SQL syntax, although I don't believe there isanything useful for this problem pre-SQL Server 2005.Thanks!Adam
Hi, I have one column of data which is 15.678 but in the excel, i format it to 15.68 ( two decimal place, so in excel i should see 15.68), when i am trying to import the data from excel to sql server by using odbc connection, it still getting 15.678, how can i get the data from 15.678 to 15.68 ( what i see is wat i get). Thanks for help.