Asp.net application suddenly stopped responding to requests - vb.net

Good day, I am a newbie in .net programming and also IIS web deployment configuration.
Currently, I have an asp.net application that runs using Framework 4.5 on IIS. For the first month of having the application deployed on the server, it was running fine and smoothly. However, recently the application had issues whereby the login page would actually load but when the users key in their credentials, the page loading timer would show and it disappears, leaving the user stranded, unable to login.
In addition, the server had undergone security procedures as stated below:
Windows Hardening (Using Windows Server 2012)
SQL Server Hardening (SQL Server 2012) and port was changed to 8001
Also, the architecture of the application is that:
The Application is deployed in AMLWEB server
The SQL Server Database is in AMLDB server
So, the connection actually goes across server and the login authentication is actually authenticated against Active Directory.
The screenshot as attached:
Unhandled exception screenshot
When checked on the event viewer, the below warning was seen that may suggest to be contributing to the issue:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 1/18/2015 5:27:15 PM
Event time (UTC): 1/18/2015 9:27:15 AM
Event ID: 2ac169fff7284e86b7b0844e5d9ccab1
Event sequence: 4
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT/AML-1-130660468323976167
Trust level: Full
Application Virtual Path: /AML
Application Path: D:\AML\
Machine name: AMLWEB
Process information:
Process ID: 6756
Process name: w3wp.exe
Account name: IIS APPPOOL\.NET v4.5
Exception information:
Exception type: InvalidOperationException
Exception message: The ConnectionString property has not been initialized.
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at DBManager.DBManager.OpenConnection(String DBStrConn, Int16 DBType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\DBManager\DBManager.vb:line 50
at DBManager.DBManager.ExecuteSQLQuery_ReturnDS(String& ReturnErrorMsg, String SqlString, String DBConnString, Int16 DBType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\DBManager\DBManager.vb:line 190
at SQLAdminQueryManager.AdminQueryManager.AdminQueryManager_Staff_Login.Staff_Login_Retreive(cor_staff AppEntity, String DbSQLConnString, String DbType, String& ReturnErrorMsg, Object& ReturnObjDataset, String AccessType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\SQLAdminQueryManager\AdminQueryManager.vb:line 65
at Login_page_LDAP_Code.LoginButton_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Request information:
Request URL: https://amlweb/AML/Login_page.aspx
Request path: /AML/Login_page.aspx
User host address: 10.1.67.61
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\.NET v4.5
Thread information:
Thread ID: 10
Thread account name: IIS APPPOOL\.NET v4.5
Is impersonating: False
Stack trace: at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at DBManager.DBManager.OpenConnection(String DBStrConn, Int16 DBType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\DBManager\DBManager.vb:line 50
at DBManager.DBManager.ExecuteSQLQuery_ReturnDS(String& ReturnErrorMsg, String SqlString, String DBConnString, Int16 DBType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\DBManager\DBManager.vb:line 190
at SQLAdminQueryManager.AdminQueryManager.AdminQueryManager_Staff_Login.Staff_Login_Retreive(cor_staff AppEntity, String DbSQLConnString, String DbType, String& ReturnErrorMsg, Object& ReturnObjDataset, String AccessType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\SQLAdminQueryManager\AdminQueryManager.vb:line 65
at Login_page_LDAP_Code.LoginButton_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Custom event details:
However, the connection string was indeed had been set up properly as below:
Web.config
<connectionStrings>
<add name="AMLDBConnectionString" connectionString="Data Source=AMLDB01, 8001;Initial Catalog=AML_DB;integrated security=true; uid=sa; pwd=p#ssw0rd"/>
</connectionStrings>
And it was set up as a global variable as so:
GlobalSQLConnString = ConfigurationManager.ConnectionStrings("AMLDBConnectionString").ToString
GlobalDBType As Int16 = 1
The line which actually executed to connect to the DB:
blnReturnValue = objSqlQuery.Staff_Login_Retreive(objBE, GlobalSQLConnString, GlobalDBType, strErrorMsgReturn, returnDS, "S")
The method invoked:
Public Function Staff_Login_Retreive(ByVal AppEntity As BusinessEntities.cor_staff, _
ByVal DbSQLConnString As String, ByVal DbType As String, _
ByRef ReturnErrorMsg As String, ByRef ReturnObjDataset As Object, _
Optional ByVal AccessType As String = "S") As Boolean
With AppEntity
SQlQuery = "SELECT * "
SQlQuery += " FROM cor_staff "
SQlQuery += " WHERE cor_staff.cor_userid =N'" & AppEntity.cor_userid & "'"
End With
'
If AccessType.ToUpper = "R" Then
ReturnObjDataset = ExecuteSQLQuery_ReturnIDR(ReturnErrorMsg, SQlQuery, DbSQLConnString, DbType)
Else
ReturnObjDataset = ExecuteSQLQuery_ReturnDS(ReturnErrorMsg, SQlQuery, DbSQLConnString, DbType)
End If
'
If ReturnErrorMsg.Trim.Length = 0 Then
Return True
Else
Return False
End If
'
End Function
Edited
Since the above code would actually run through and would actually be invoked on this line:
ReturnObjDataset = ExecuteSQLQuery_ReturnDS(ReturnErrorMsg, SQlQuery, DbSQLConnString, DbType)
The connection would only be opened here:
Public Function ExecuteSQLQuery_ReturnDS(ByRef ReturnErrorMsg As String, ByVal SqlString As String, ByVal DBConnString As String, ByVal DBType As Int16) As DataSet
ReturnErrorMsg = ""
Dim DS As New DataSet
'
If DBType = 1 Then
Try
OpenConnection(DBConnString, DBType)
Dim sqlCmd As New SqlCommand(SqlString, sqlConn)
sqlCmd.CommandTimeout = 0
Dim sqlDaAdp As New SqlDataAdapter(sqlCmd)
sqlDaAdp.Fill(DS)
sqlCmd = Nothing
sqlDaAdp = Nothing
CloseConnection(DBType)
Return DS
Catch ex As SqlException
If ex.Number = 18456 Or ex.Number = 4060 Then
ReturnErrorMsg = "Database Connection Error >> Error No : " & ex.Number
Else
ReturnErrorMsg = "SQL Statement Error >> Error No : " & ex.Number
End If
CloseConnection(DBType)
Return Nothing
End Try
ElseIf DBType = 3 Then
Try
OpenConnection(DBConnString, DBType)
Dim oledbCmd As New OleDbCommand(SqlString, oleDbconn)
Dim oledbDaAdp As New OleDbDataAdapter(oledbCmd)
oledbDaAdp.Fill(DS)
oledbDaAdp = Nothing
oledbDaAdp = Nothing
CloseConnection(DBType)
Return DS
Catch ex As OleDbException
If ex.ErrorCode = -2147217887 Then
ReturnErrorMsg = "Database Connection Error >> Error Code : " & ex.ErrorCode
Else
ReturnErrorMsg = "SQL Statement Error >> Error Code : " & ex.ErrorCode
End If
CloseConnection(DBType)
Return Nothing
End Try
End If
'
Return Nothing
'
End Function
Open connection method:
Public Sub OpenConnection(ByVal DBStrConn As String, ByVal DBType As Int16)
Try
If DBType = 1 Then
sqlConn = New SqlConnection(DBStrConn)
If sqlConn.State = ConnectionState.Closed Then
sqlConn.Open()
Else
sqlConn.Close()
sqlConn.Open()
End If
ElseIf DBType = 3 Then
oleDbconn = New OleDbConnection(DBStrConn)
If oleDbconn.State = ConnectionState.Closed Then
oleDbconn.Open()
Else
oleDbconn.Close()
oleDbconn.Open()
End If
End If
'
Catch ex As Exception
Throw
End Try
End Sub
End of edited part
Does anyone have any idea why does such exception would occur?
So far, I've done the following to actually try to debug this issue:
Restart IIS
Restart Application Pool
Recycle Application Pool (every 12 hours, 8 a.m. and 8 p.m. specifically)
Restart SQL Server Service
None of the above worked. But when I actually tried accessing the application from a specific floor in which is the Security Team floor, the application actually starts functioning as usual, and others could actually access the application as well.
Please help, I'm totally going out of my mind about this issue.
Does it have anything to do with my deployment method, iis configuration or programming, I'm willing to listen to suggestions.
Thanks for your time.

Related

AccessViolationException with provider OraOLEDB.Oracle on 12C?

We were using Oracle 11g with MSDAORA as a provider but since MSDAORA will be deprecated we have to move to a new provider for the connection string. We're also using Oracle Client 12c right now
Before we were using: Provider=MSDAORA.1;Password=;User ID=;Data Source=****11G.WORLD; Persist Security Info=True
Now we're trying to use: Provider=OraOLEDB.Oracle;OLEDB.NET=true;PLSQLRSet=true; Password=;User ID=*;Data Source=****11G.world;Persist Security Info=True
The problem is IIS crashes, and we got this exception, we have been trying to solve this issue for weeks and no luck yet:
Exception Details
SystemAccessViolationException Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Data.Common.UnsafeNativeMethods.1CommandTextExecute(IntPtr pUnkOuter, Guid& riid, tagDBPARAMS pDBParams, IntPtr& pcRowsAffected,
Object& ppRowset)
at System.Data.01eDb.0IeDbCommand.ExecuteCommandTextForSingleResult(tagDBPAFtAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.01eDb.01eDbCommand.ExecuteReaderIntemal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.01eDb.0IeDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.Filllnternal(DataSet dataset, DataTable0 datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTableD dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at M.Planned_DataloadDataCurGrid() in D: Projects\ M\Planned_Data.aspx.vb:line 637
at M.Planned_Data.cmbProgram_SelectedIndexChanged(Object sender, EventArgs e) in DAProjectAM \Planned_Data.aspx.vb:line
484
at System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs
e)
at System.Web.ULWebControls.DropDownListRaisePostDataChangedEvent()
at System.Web.UI.WebControls.DropDownListSystem.Web.ULIPostBackDataHandler.RaisePostDataChangedEvento
at System.Web.ULPage.RaiseChangedEvents()
This is a simple minimum reproduction:
Public Sub LoadGrid()
Dim ocn As OleDbConnection = New OleDbConnection("Provider=OraOLEDB.Oracle;OLEDB.NET=true;PLSQLRSet=true; Password=*****;User ID=*****;Data Source=****11G.world;Persist Security Info=True")
Dim oda As New OleDbDataAdapter
Dim odataSet As New DataTable
Dim opm As OleDbParameter
Dim oCmd As New OleDbCommand
opm = New OleDbParameter("pi_language_code", OleDbType.Char)
opm.Value = "E"
oCmd.Parameters.Add(opm)
opm = New OleDbParameter("pi_year_id", OleDbType.Integer)
opm.Value = "2020"
oCmd.Parameters.Add(opm)
opm = New OleDbParameter("pi_month_id", OleDbType.Integer)
opm.Value = "2"
oCmd.Parameters.Add(opm)
opm = New OleDbParameter("pi_program_id", OleDbType.Integer)
opm.Value = "4"
oCmd.Parameters.Add(opm)
opm = New OleDbParameter("pi_location_id", OleDbType.Integer)
opm.Value = "2"
oCmd.Parameters.Add(opm)
Try
ocn.Open()
oCmd.Connection = ocn
oCmd.CommandType = CommandType.StoredProcedure
oCmd.CommandText = "***********"
oCmd.ExecuteNonQuery()
oda.SelectCommand = oCmd
odataSet.Clear()
oda.Fill(odataSet) 'This is where it crashes
Dim rowcount As Integer = odataSet.Rows.Count
dgCurrentYear.DataSource = odataSet
dgCurrentYear.DataBind()
If rowcount > 0 Then
dgCurrentYear.Visible = True
Else
dgCurrentYear.Visible = False
End If
Catch ex As OleDbException
' Display the error
Catch ex As Exception
' Display the error
Finally
' Clean up
If (Not ocn Is Nothing) AndAlso (Not ocn.State = ConnectionState.Closed) Then
ocn.Close()
End If
ocn = Nothing
opm = Nothing
End Try
End Sub
so we solved the problem by removing the line oCmd.ExecuteNonQuery()
Because I don't have to call ExecuteNonquery since the fill method of the DataAdapter is taking care of that.
Programming Practice: Using ExecuteNonQuery with SqlDataAdapter

System.Web.Services.Protocols.SoapException

This error is generated in a ratio of 5:1. 4 times it will work without error, but the next time it runs it will return the error "Object reference not set to an instance of an object" for the same query string.
My system uses a web service (SVC) to connect to a MySql database for all of its CRUD operations. The Error is listed below:
System.Web.Services.Protocols.SoapException: DELETE FROM
customer_number WHERE cus_id =4 Object reference not set to an
instance of an object. at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters) at
POS.ThePOSServerService.PosMain.ExecuteQueryBool(String strQuery,
String Company, String User, String Pass) in Reference.vb:line 266
While the code that generates error is as follows with line numbers:
Try
261 Dim ConnectionString As String = _
ConfigurationManager.ConnectionStrings(Company).ConnectionString
262 'Dim sCommand As StringBuilder = New 262 - StringBuilder(strQuery)
263 Using mConnection As MySqlConnection = New MySqlConnection(ConnectionString)
264 mConnection.Open()
265 Using myCmd As MySqlCommand = New MySqlCommand(strQuery, mConnection)
266 myCmd.CommandType = CommandType.Text
267 Result = myCmd.ExecuteNonQuery() > 0
268 End Using
269 End Using
Catch ex As Exception
Throw New ApplicationException(ex.ToString)
End Try
I just want to get Result to be True or False to return as a value.
It is my fault. never checked that the connection string was correctly coming into the function. once I corrected that (giving the correct connection string) everything went as I was expecting. Thanks to all anyway.

Is this err caused by trying to process too many controls on the web form?

I get this err page:
Server Error in '/EMS/customerreportingnet' Application.
Operation is not valid due to the current state of the object.
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.InvalidOperationException: Operation is not valid due to the current state of the object.
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:
[InvalidOperationException: Operation is not valid due to the current state of the object.]
System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +4198079
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +60
System.Web.HttpRequest.FillInFormCollection() +189
[HttpException (0x80004005): The URL-encoded form data is not valid.]
System.Web.HttpRequest.FillInFormCollection() +11196408
System.Web.HttpRequest.get_Form() +119
System.Web.TraceContext.InitRequest() +1188
System.Web.TraceContext.VerifyStart() +133 System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +11307449
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +452
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5485; ASP.NET Version:2.0.50727.5491
...when I click the button which fires this code:
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim upd8DML As String = "UPDATE CustomerCategoryLog SET Category = 'Exploding' WHERE Unit = #Unit And MemberNo = #MemberNo AND Custno = #CustNo"
Dim coName As String
Dim argVals(2) As String
Dim _Unit As String
Dim _MemberNo As String
Dim _CustNo As String
Dim curIndexVal As String
For Each cntrl As Control In Me.Controls
If TypeOf cntrl Is CheckBox Then
If DirectCast(cntrl, CheckBox).Checked = True Then
curIndexVal = DirectCast(cntrl, CheckBox).ID
coName = GetLabelTextForID(curIndexVal)
argVals = GetArgValsForCompanyName(coName)
_Unit = argVals(0)
_MemberNo = argVals(1)
_CustNo = argVals(2)
Using conn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")), _
cmd As New SqlCommand(upd8DML, conn)
cmd.Parameters.Add("#Unit", SqlDbType.VarChar, 50).Value = _Unit
cmd.Parameters.Add("#MemberNo", SqlDbType.VarChar, 50).Value = _MemberNo
cmd.Parameters.Add("#CustNo", SqlDbType.VarChar, 50).Value = _CustNo
conn.Open
cmd.ExecuteScalar()
End Using
End If
End If
Next
End Sub
My guess is that this is because the literally thousands of label/checkbox pairs of controls on the form are too much to handle (no pun intended). If this reckoning is right, what is the limit of controls that the page will host without whin[g]ing?
Is there a workaround where I can deal with thousands of label/checkbox pairs?
Or is it the number of update statements that are causing the problem?
The err msg seems to indicate too many controls to deal with...

Can't send email with proxy server

I'm having a problem inside work, trying to send an email.
I think this is because we use a Proxy Server, however I can't find anyway of programming a proxy into VB.net, any helpers?
I keep getting the following error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 173.194.66.109:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at SENpic.Email.butSendEmail_Click(Object sender, EventArgs e) in C:\Users\Graham\Documents\Visual Studio 2010\Projects\Email Project\EmailTest\Email.vb:line 28
Here is the code:
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential("mymail#gmail.com", "password")
Smtp_Server.Port = 25 '587
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress(txtEmailFrom.Text, "SENpic CSP")
e_mail.To.Add("fred2000#aol.com")
e_mail.Subject = txtEmailSubject.Text
e_mail.IsBodyHtml = False
e_mail.Body = txtEmailMessage.Text
Smtp_Server.Send(e_mail)
MsgBox("Your email has been sent", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "EMail...")
Catch error_t As Exception
WriteToLogFile("Email: ", error_t.ToString)
MsgBox(error_t.ToString)
End Try
Any help is much appreciated.
Thanks
Graham

Getting Error at insert on Visual Basic .Net

im trying to make an insert to my Database and im receiving an error, is my first time with VB.Net so any help would be greatly appreciated.
Here is the code:
Sub InsertGestion(ByVal s As Object, ByVal e As EventArgs)
Dim Records() As String
Records = Split(TBComment.Text, vbCrLf)
Dim record As Integer
For record = 0 To UBound(Records)
oracleCommand = New OracleCommand("INSERT INTO ACTFIL (ACACCTG,ACACCT,ACACTDTE,ACSEQNUM,ACACCODE,ACRCCODE,ACCIDNAM,ACCOMM) values ('1','" + TBNum.text + "','" + TBFecha.Text + "',"+ (record+1) +",'"+TBCodAc.text+"','"+TBCodRes.text+"','"+TBGestor.Text+"','"+record+"')", oracleConexion)
Try
oracleConexion.Open()
oracleCommand.ExecuteNonQuery()
Catch ex As Exception
status.Text = "ERROR al insertar la gestiĆ³n " + ex.Message + "'" '& ex.Message
Finally
oracleConexion.Close()
Response.Redirect("gestiones.aspx?credito=" + Request.QueryString("credito") + "")
End Try
Next
End Sub
And the Error:
FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +717374
Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +114
[InvalidCastException: Conversion from string "INSERT INTO ACTFIL (ACACCTG,ACAC" to type 'Double' is not valid.]
Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +717687
ASP.marcador_gestiones_aspx.InsertGestion(Object s, EventArgs e) in G:\vta-paqV2\marcador\gestiones.aspx:62
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
This was originally an update and it was working, i just modified the OracleCommand.
Btw, i notice this is not a secure way to execute the queries, if someone can point me on the right direction i'd really appreciate it.
Extract the oracle command from the query and run on Oracle client. That will let you know if there is anything wrong with your oracle command.
Secondly you can use string.format to form your query rather using + operator.
Secure approach to deal with query inputs is through input parameters. You can check below links.
http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracleparameter.aspx
http://blogs.msdn.com/b/alextch/archive/2007/08/21/using-data-parameters-with-oracle-data-provider-for-net.aspx
I hope this helps.
Thanks!
Dhananjay