473,382 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Urgent please take a look and help if you can

hi guys

I posted the other day regarding a solution i needed to design, im new to development an asp,net and built a local post office search tool using asp.net 2. vb in visual studio, using an sql express mdf database(this means the database is transferable with the solution even if the server doesnt have sql server on it) The app works fine, users can search, admins can edit data, insert and delete. The site also has membership and role management.

My problem is that i needed to be able to have a user browse a csv file and upload it into a datagrid and then the database. ive got the following but recieve an error when running it.

upload.aspx
Expand|Select|Wrap|Line Numbers
  1. %@ Page Language="VB"%>
  2. <%@ Import Namespace="system.io" %>
  3. <%@ Import Namespace="System.Data" %>
  4. <%@ Import Namespace="system.data.sqlclient" %>
  5. <%@ Import Namespace="system.configuration" %>
  6.  
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8.  
  9. <script runat="server">
  10.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  11.         If (IsPostBack) Then
  12.             Grid.Visible = True
  13.         Else
  14.             Grid.Visible = False
  15.         End If
  16.     End Sub
  17.     Protected Sub UploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  18.         If OpenFileDialog1.HasFile Then
  19.             Dim fi As New FileInfo(OpenFileDialog1.FileName)
  20.             Dim strConn As String = System.Configuration.ConfigurationManager.AppSettings("connectionstring") & fi.DirectoryName
  21.             Dim connection As New SqlConnection("strConn")
  22.             Dim MySql As String = "SELECT * FROM " & fi.Name
  23.             Dim objDR As SqlDataReader
  24.             Dim Cmd As New SqlCommand(MySql, connection)
  25.             connection.Open()
  26.             objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
  27.             Grid.DataSource = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
  28.             Grid.DataBind()
  29.         Else
  30.             Label1.Text = "You have not specified a file."
  31.         End If
  32.     End Sub
  33. </script>
  34.  
The webconfig file
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  3.     <connectionStrings>
  4.         <remove name="LocalSqlServer" />
  5.         <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|PostOffice.mdf;User Instance=true"
  6.             providerName="System.Data.SqlClient" />
  7.         <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\PostOffice.mdf;Integrated Security=True;User Instance=True"
  8.             providerName="System.Data.SqlClient" />
  9.     </connectionStrings>
  10.     <system.web>
  11.         <roleManager enabled="true" />
  12.         <authentication mode="Forms" />
  13.     </system.web>
  14. </configuration>
  15.  
the error message
Server Error in '/MerlinLocalPostOfficeApp' Application.
--------------------------------------------------------------------------------

Format of the initialization string does not conform to specification starting at index 0.
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:


Line 19: Dim fi As New FileInfo(OpenFileDialog1.FileName)
Line 20: Dim strConn As String = System.Configuration.ConfigurationManager.AppSetti ngs("connectionstring") & fi.DirectoryName
Line 21: Dim connection As New SqlConnection("strConn")
Line 22: Dim MySql As String = "SELECT * FROM " & fi.Name
Line 23: Dim objDR As SqlDataReader


Source File: c:\inetpub\wwwroot\MerlinLocalPostOfficeApp\Admini strator\Upload2.aspx Line: 21

Stack Trace:


[ArgumentException: Format of the initialization string does not conform to specification starting at index 0.]
System.Data.Common.DbConnectionOptions.GetKeyValue Pair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +1242
System.Data.Common.DbConnectionOptions.ParseIntern al(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +128
System.Data.Common.DbConnectionOptions..ctor(Strin g connectionString, Hashtable synonyms, Boolean useOdbcRules) +102
System.Data.SqlClient.SqlConnectionString..ctor(St ring connectionString) +52
System.Data.SqlClient.SqlConnectionFactory.CreateC onnectionOptions(String connectionString, DbConnectionOptions previous) +24
System.Data.ProviderBase.DbConnectionFactory.GetCo nnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +125
System.Data.SqlClient.SqlConnection.ConnectionStri ng_Set(String value) +56
System.Data.SqlClient.SqlConnection.set_Connection String(String value) +4
System.Data.SqlClient.SqlConnection..ctor(String connectionString) +21
ASP.administrator_upload2_aspx.UploadButton_Click( Object sender, EventArgs e) in c:\inetpub\wwwroot\MerlinLocalPostOfficeApp\Admini strator\Upload2.aspx:21
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102


Please try and help in anyway, im a really newbie so try and dumb it down for me.

Thanks in advance
Feb 14 '07 #1
1 3173
kenobewan
4,871 Expert 4TB
Most likely cause of initial error is the connection string. Please see: Connection Strings. Your connection string looks a problem too...
Feb 15 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rajesh Garg | last post by:
I have a scenario like this....... update esan set tes_address_city = 'TEST1' --at some time update esan set tes_address_city = 'TEST12' --at some time update esan set tes_address_city =...
6
by: Rajesh Garg | last post by:
I have actually extended my request I have a scenario like this....... update esan set tes_address_city = 'TEST1' --at some time update esan set tes_address_city = 'TEST12' --at some time...
3
by: Liu Ju | last post by:
Dear members: I want to use the multithread in my program which is developed in Visual C++ platform (version 6). I created a controlling function: UINT CCOMM1Dlg::WritingThreadFunc(LPVOID...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
1
by: Rahul S. | last post by:
Hey all: I need urgent information how to set the environment in Visual.NET wiritng in C. I am working with a licensed version of the Analyze 6.0 software from mayo clinic. I need to write...
3
by: Rahul S. | last post by:
Hey all: I need urgent information how to set the environment in Visual.NET wiritng in C. I am working with a licensed version of the Analyze 6.0 software from mayo clinic. I need to write...
1
by: newbie | last post by:
Hi I am using a toolkit written in c++ that consists of three parts 1) video captur 2) image processin 3) OpenGL wrappe The video capture program only works with local hardware (for...
5
by: VB Programmer | last post by:
When I go to create a new ASP.NET web application VS 2003 freezes on this message: Contacting server to create Web project 'WebApplication1'... I checked my file system and the...
17
by: Saps | last post by:
Hi all. Can anyone help me here. I have loads of .sql files and i need a way to call these from my asp page so the user can run them from the browser. Meaning i have a page with a list of all...
3
by: settyv | last post by:
Hi, I need to generate PDF stream when i click on Linkbutton in datagrid ..At present i hardcoded the DMS Id and now it is working.But i need to pass DMS ID when click linkbutton.How can i do...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.