Your previous post now shows a different error, which is completely seperate to the date formatting issue. Are you saying that you are still receiving that error or is the error now
"Specified argument was out of the range of valid values. Parameter name: index"? If this is the case then the link provided below should give you the answer that you are looking for.
so now the date and time stamp error is gone i just need one error to be fixed now
An SqlParameter with ParameterName '@opentime' is not contained by this SqlParameterCollection.
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.IndexOutOfRangeException: An SqlParameter with ParameterName '@opentime' is not contained by this SqlParameterCollection.
Source Error:
Line 104: sqldatenull = SqlDateTime.Null
Line 105: End If
Line 106: cmd.Parameters("@opentime").Value = GridView2.Rows.Item(i).Cells(4).Text
Line 107: cmd.ExecuteNonQuery()
Line 108: If i = GridView2.Rows.Count - 1 Then
Source File: c:\inetpub\wwwroot\dispatcher.aspx.vb Line: 106
Stack Trace:
[IndexOutOfRangeException: An SqlParameter with ParameterName '@opentime' is not contained by this SqlParameterCollection.]
System.Data.SqlClient.SqlParameterCollection.GetParameter(String parameterName) +768517
System.Data.SqlClient.SqlParameterCollection.get_Item(String parameterName) +8
dispatcher.Button2_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\abn\dispatcher.aspx.vb:106
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.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) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
I believe the reason you are receiving this error message is because the parameter hasn't been added to the collection, replace the following code. Cmd.parameters.("@opentime").value = ... With Cmd.parameters.add("@opentime").value = ...
Marked as answer by Rashaad786 on Feb 12, 2013 11:14 AM
Hi i have tried that and that issue has been solved
i am getting a differen error now
Server Error in '/abn' Application.
There is already an open DataReader associated with this Command which must be closed first.
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: There is already an open DataReader associated with this Command which must be closed first.
Source Error:
Line 107: cmd.Parameters("@opentime").Value = GridView2.Rows.Item(i).Cells(4).Text.ToString("yyyy-MM-dd")
Line 108: End If
Line 109: cmd.ExecuteNonQuery()
Line 110: If i = GridView2.Rows.Count - 1 Then
Line 111: Response.Redirect("dispatcher.aspx")
Source File: c:\inetpub\wwwroot\xxx\dispatcher.aspx.vb Line: 109
Stack Trace:
[InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.]
System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command) +795219
System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command) +21
System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) +99
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +75
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
dispatcher.Button2_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\xxx\dispatcher.aspx.vb:109
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.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) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
I will quite happily help you resolving this issue, but could you please "Mark as Answer" my previous replies that have fixed your errors.
It seems that prior to this line of code there is a DataReader that is already open. Without seeing what coding there is before Line 107 I will be unable to fix this one.
Login failed for user 'username'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)
then i installed ms SQL Server Management Studio and attached the database and then i did add the user to the dbadmin team now the whole app is not working please can you assist me
Server Error in '/xxx' Application.
Cannot open user default database. Login failed.
Login failed for user 'xxxx\ASPNET'.
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.Data.SqlClient.SqlException: Cannot open user default database. Login failed.
Login failed for user 'xxxx\ASPNET'.
Source Error:
Line 24: connection = GetConnString()
Line 25: cn = New SqlClient.SqlConnection(connection)
Line 26: cn.Open()
Line 27: cmd = New SqlClient.SqlCommand("SELECT role, username, team FROM [user] WHERE (empid =@myname ) AND (pwd =@password )", cn)
Line 28: cmd.Parameters.Add("@myname", SqlDbType.NVarChar)
Source File: c:\inetpub\wwwroot\xxxxx\Login.aspx.vb Line: 26
Stack Trace:
[SqlException (0x80131904): Cannot open user default database. Login failed.
Login failed for user 'CALLBACK\ASPNET'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800131
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +172
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
_Login.Lgnbtn_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\abn\Login.aspx.vb:26
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.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) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
can you please assist me thru team vieuwer im not that good with vb.net i realy need some help
Marked as answer by Rashaad786 on Feb 12, 2013 03:45 PM
Rashaad786
Member
6 Points
16 Posts
Re: Date and timestamps error
Jan 31, 2013 05:10 AM|LINK
The issue that i was getting is still not resolved the code posted is the complete .vb script link to that asp page
JammoD
Member
242 Points
49 Posts
Re: Date and timestamps error
Jan 31, 2013 09:51 AM|LINK
Your previous post now shows a different error, which is completely seperate to the date formatting issue. Are you saying that you are still receiving that error or is the error now "Specified argument was out of the range of valid values. Parameter name: index"? If this is the case then the link provided below should give you the answer that you are looking for.
http://forums.asp.net/t/1249807.aspx/1
If you wish to provide the Souce code for the layout, combined with the code behind, I may be able to recreate the error and help you solve it.
Thanks,
Rashaad786
Member
6 Points
16 Posts
Re: Date and timestamps error
Feb 08, 2013 11:58 AM|LINK
i have used the sql parameters in there
Dim sqldatenull As SqlDateTime
sqldatenull = SqlDateTime.Null
so now the date and time stamp error is gone i just need one error to be fixed now
An SqlParameter with ParameterName '@opentime' is not contained by this SqlParameterCollection. 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.IndexOutOfRangeException: An SqlParameter with ParameterName '@opentime' is not contained by this SqlParameterCollection. Source Error: Line 104: sqldatenull = SqlDateTime.Null Line 105: End If Line 106: cmd.Parameters("@opentime").Value = GridView2.Rows.Item(i).Cells(4).Text Line 107: cmd.ExecuteNonQuery() Line 108: If i = GridView2.Rows.Count - 1 Then Source File: c:\inetpub\wwwroot\dispatcher.aspx.vb Line: 106 Stack Trace: [IndexOutOfRangeException: An SqlParameter with ParameterName '@opentime' is not contained by this SqlParameterCollection.] System.Data.SqlClient.SqlParameterCollection.GetParameter(String parameterName) +768517 System.Data.SqlClient.SqlParameterCollection.get_Item(String parameterName) +8 dispatcher.Button2_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\abn\dispatcher.aspx.vb:106 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.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) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746JammoD
Member
242 Points
49 Posts
Re: Date and timestamps error
Feb 08, 2013 06:07 PM|LINK
Rashaad786
Member
6 Points
16 Posts
Re: Date and timestamps error
Feb 10, 2013 10:37 PM|LINK
Hi i have tried that and that issue has been solved
i am getting a differen error now
Server Error in '/abn' Application. There is already an open DataReader associated with this Command which must be closed first. 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: There is already an open DataReader associated with this Command which must be closed first. Source Error: Line 107: cmd.Parameters("@opentime").Value = GridView2.Rows.Item(i).Cells(4).Text.ToString("yyyy-MM-dd") Line 108: End If Line 109: cmd.ExecuteNonQuery() Line 110: If i = GridView2.Rows.Count - 1 Then Line 111: Response.Redirect("dispatcher.aspx") Source File: c:\inetpub\wwwroot\xxx\dispatcher.aspx.vb Line: 109 Stack Trace: [InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.] System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command) +795219 System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command) +21 System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) +99 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +75 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 dispatcher.Button2_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\xxx\dispatcher.aspx.vb:109 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.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) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746JammoD
Member
242 Points
49 Posts
Re: Date and timestamps error
Feb 11, 2013 12:29 PM|LINK
Hi,
I will quite happily help you resolving this issue, but could you please "Mark as Answer" my previous replies that have fixed your errors.
It seems that prior to this line of code there is a DataReader that is already open. Without seeing what coding there is before Line 107 I will be unable to fix this one.
Thanks,
Rashaad786
Member
6 Points
16 Posts
Re: Date and timestamps error
Feb 12, 2013 12:15 PM|LINK
Hi ,
I am sorry is my first time using these forums i have marked them as answer
I have managed to solve that error by changing my connection string to
ConnectionString="Data Source=CALLBACK\SQLEXPRESS;Initial Catalog=tracker.mdf;Persist Security Info=True;MultipleActiveResultSets=True;User ID=user;password=pass"providerName="System.Data.SqlClient"/>
Then i got the error message that
Login failed for user 'username'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)
then i installed ms SQL Server Management Studio and attached the database and then i did add the user to the dbadmin team now the whole app is not working please can you assist me
Server Error in '/xxx' Application. Cannot open user default database. Login failed. Login failed for user 'xxxx\ASPNET'. 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.Data.SqlClient.SqlException: Cannot open user default database. Login failed. Login failed for user 'xxxx\ASPNET'. Source Error: Line 24: connection = GetConnString() Line 25: cn = New SqlClient.SqlConnection(connection) Line 26: cn.Open() Line 27: cmd = New SqlClient.SqlCommand("SELECT role, username, team FROM [user] WHERE (empid =@myname ) AND (pwd =@password )", cn) Line 28: cmd.Parameters.Add("@myname", SqlDbType.NVarChar) Source File: c:\inetpub\wwwroot\xxxxx\Login.aspx.vb Line: 26 Stack Trace: [SqlException (0x80131904): Cannot open user default database. Login failed. Login failed for user 'CALLBACK\ASPNET'.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800131 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +172 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105 System.Data.SqlClient.SqlConnection.Open() +111 _Login.Lgnbtn_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\abn\Login.aspx.vb:26 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.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) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746can you please assist me thru team vieuwer im not that good with vb.net i realy need some help
Rashaad786
Member
6 Points
16 Posts
Re: Date and timestamps error
Feb 12, 2013 03:47 PM|LINK
Hi that i have solved aswel i just need this error solved ive been debugging this the whole dayServer Error in '/abn' Application. Login failed for user 'callback'. 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.Data.SqlClient.SqlException: Login failed for user 'callback'. Source Error: Line 73: Line 74: cn = New SqlClient.SqlConnection(connection) Line 75: cn.Open() Line 76: cmd = New SqlClient.SqlCommand("SELECT agentname FROM [dailytickets] WHERE callid=@tktnumber", cn) Line 77: cmd.Parameters.Add("@tktnumber", SqlDbType.VarChar) Source File: c:\inetpub\wwwroot\xxx\dispatcher.aspx.vb Line: 75 Stack Trace: [SqlException (0x80131904): Login failed for user 'callback'.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800131 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +172 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105 System.Data.SqlClient.SqlConnection.Open() +111 dispatcher.Button2_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\abn\dispatcher.aspx.vb:75 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.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) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746JammoD
Member
242 Points
49 Posts
Re: Date and timestamps error
Feb 13, 2013 12:20 PM|LINK
Hi Rashaad,
I need to see the code from the code behind file and not from the error displayed.
Thanks,
Rashaad786
Member
6 Points
16 Posts
Re: Date and timestamps error
Feb 13, 2013 12:46 PM|LINK
Hi ,
here with the code
Dim sqldatenull As SqlDateTime Dim objDataReader As SqlDataReader sqldatenull = SqlDateTime.Null Dim connection As String connection = "Data Source=.\SQLEXPRESS;AttachDbFilename=c:\inetpub\wwwroot\xxx\App_Data\tracker.mdf;Integrated Security=True;User Instance=True;Connection TimeOut=60;MultipleActiveResultSets=True;" cn = New SqlClient.SqlConnection(connection) cn.Open() cmd = New SqlClient.SqlCommand("SELECT agentname FROM [dailytickets] WHERE callid=@tktnumber", cn) cmd.Parameters.Add("@tktnumber", SqlDbType.VarChar) cmd.Parameters("@tktnumber").Value = GridView2.Rows.Item(i).Cells(5).Text dr = cmd.ExecuteReader() If dr.Read = 0 Then cn.Close() cn.Open() cmd = New SqlClient.SqlCommand("INSERT INTO [dailytickets] (agentname, callid, username, country, contact, dispatcher, status, title, submitdate, site, dispatchtime, resolution, opentime)VALUES (@name,@tktnumber,@usrname,@region,@contact,@dispatcher,@status,@summary,@submitdate,@site,@dispatchtime,@resolution,@opentime)", cn) cmd.Parameters.Add("@name", SqlDbType.VarChar) cmd.Parameters("@name").Value = GridView2.Rows.Item(i).Cells(10).Text cmd.Parameters.Add("@tktnumber", SqlDbType.VarChar) cmd.Parameters("@tktnumber").Value = GridView2.Rows.Item(i).Cells(5).Text cmd.Parameters.Add("@usrname", SqlDbType.VarChar) cmd.Parameters("@usrname").Value = GridView2.Rows.Item(i).Cells(0).Text cmd.Parameters.Add("@region", SqlDbType.VarChar) cmd.Parameters("@region").Value = GridView2.Rows.Item(i).Cells(6).Text cmd.Parameters.Add("@contact", SqlDbType.VarChar) cmd.Parameters("@contact").Value = GridView2.Rows.Item(i).Cells(2).Text cmd.Parameters.Add("@dispatcher", SqlDbType.VarChar) cmd.Parameters("@dispatcher").Value = GridView2.Rows.Item(i).Cells(11).Text cmd.Parameters.Add("@status", SqlDbType.VarChar) cmd.Parameters("@status").Value = GridView2.Rows.Item(i).Cells(3).Text cmd.Parameters.Add("@summary", SqlDbType.VarChar) cmd.Parameters("@summary").Value = GridView2.Rows.Item(i).Cells(7).Text cmd.Parameters.Add("@submitdate", SqlDbType.DateTime) cmd.Parameters("@submitdate").Value = GridView2.Rows.Item(i).Cells(12).Text cmd.Parameters.Add("@site", SqlDbType.VarChar) cmd.Parameters("@site").Value = GridView2.Rows.Item(i).Cells(8).Text cmd.Parameters.Add("@dispatchtime", SqlDbType.DateTime) cmd.Parameters("@dispatchtime").Value = GridView2.Rows.Item(i).Cells(13).Text cmd.Parameters.Add("@resolution", SqlDbType.VarChar) cmd.Parameters("@resolution").Value = GridView2.Rows.Item(i).Cells(9).Text cmd.Parameters.Add("@opentime", SqlDbType.DateTime) cmd.Parameters("@opentime").Value = GridView2.Rows.Item(i).Cells(4).Text End If cmd.ExecuteNonQuery() If i = GridView2.Rows.Count - 1 Then Response.Redirect("dispatcher.aspx") End If thank you in advanced for youre help