when iam exporting xl data to sqlserver through vb.net i get this error message
msg is
Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
My Code
Dim excelConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;""" ' Create Connection to Excel Workbook Dim connection As New OleDbConnection(excelConnectionString) Dim command = New OleDbCommand("Select * FROM [Data$]", connection) connection.Open() ' Create DbDataReader to Data Worksheet Dim dr As OleDbDataReader = command.executereader() ' SQL Server Connection String Dim sqlConnectionString As String = "Data Source=192.168.0.2; Initial Catalog=bagbrow_db;Integrated Security=True" ' Bulk Copy to SQL Server Dim bulkCopy As New SqlBulkCopy(sqlConnectionString) bulkCopy.DestinationTableName = "sms_data" bulkCopy.WriteToServer(dr)
************************* My web.cofig file is********************if i need any changes in web.config
<?xml version="1.0"?> <!-- Note: As an alternative to hand editing this file you can use the web admin tool to configure settings for your application. Use the Website->Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in \Windows\Microsoft.Net\Framework\v2.x\Config --> <configuration> <system.net> <mailSettings> <smtp> <network host="mail.fortunedigitals.com" port="25" userName="info@fortunedigitals.com" password="infomail"/> </smtp> </mailSettings> </system.net> <!--<sessionState mode="InProc" stateConnectionString="tcpip=192.168.0.2" sqlConnectionString="data source=192.168.0.2;Trusted_Connection=yes" cookieless="false" timeout="20" />-->
<appSettings> <add key="connString" value="server=192.168.0.2;Initial Catalog=bagbrow_db;User ID=sa;Password=sa;"/> <!--<add key="connString" value="server=72.18.135.171,1533;Initial Catalog=bagbrow_db;User ID=bagbrow_dbuser;Password=hyderabad"/>--> </appSettings> <connectionStrings> <!--<add name="connString" connectionString="Data Source=72.18.135.171,1533;Initial Catalog=bagbrow_db;User ID=bagbrow_dbuser;Password=hyderabad" providerName="System.Data.SqlClient"/>--> <add name="connstring" connectionString="Data Source=192.168.0.2;Initial Catalog=bagbrow_db;User ID=sa;Password=sa" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development.
Visual Basic options: Set strict="true" to disallow all data type conversions where data loss can occur. Set explicit="true" to force declaration of all variables. --> <compilation debug="true" strict="false" explicit="true"> <!--<assemblies> <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies>--> </compilation> <pages> <namespaces> <clear/> <add namespace="System"/> <add namespace="System.Collections"/> <add namespace="System.Collections.Specialized"/> <add namespace="System.Configuration"/> <add namespace="System.Text"/> <add namespace="System.Text.RegularExpressions"/> <add namespace="System.Web"/> <add namespace="System.Web.Caching"/> <add namespace="System.Web.SessionState"/> <add namespace="System.Web.Security"/> <add namespace="System.Web.Profile"/> <add namespace="System.Web.UI"/> <add namespace="System.Web.UI.WebControls"/> <add namespace="System.Web.UI.WebControls.WebParts"/> <add namespace="System.Web.UI.HtmlControls"/> </namespaces> </pages> <!-- The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> <authentication mode="Windows"/> <identity impersonate="true" /> <!-- The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> <customErrors mode="Off"></customErrors>
--> <customErrors mode="Off"></customErrors> </system.web> </configuration>
|
| Author: Deepika Haridas 05 Jul 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hi,
Check this link
http://geekswithblogs.net/ranganh/archive/2005/05/25/40503.aspx
You might some help regarding it..
Thanks & Regards, Deepika Editor
If U want to shine like a SUN..First U have to burn like the SUN!! Need a Guide? Join my mentor program..
|