Home » SQL Server

DSN Less Connection String format


I have able to connect the Access database using ODBC Connection in X64 OS.

For connection i have used the following code :


CString strDBDriver = _T("ODBC;Provider=MSDASQL;Driver={Microsoft Access Driver (*.mdb, *.accdb)};UID=NULL;PWD=NULL;");

CString strDBPath  = _T("dbq=C:\\TestDB\\TestDatabase.mdb");

Cstring strConnPath = strDBDriver + strDBPath;

CDatabase pDB;



pDB.OpenEx(strConnPath, CDatabase::noOdbcDialog)



I can connect the database and perform my operations. Now, the problem is on closing or exit of my application following warning is displayed in DEBUG mode.

Warning: ODBC Success With Info, _CrtDbgReport: String too long or IO Error_CrtDbgReport: String too long or IO Error_CrtDbgReport: String too long or IO ErrorState:S1000,Native:63,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]


On searching, i found that ODBC error 01S00 means , supplying of wrong connection string info.

So, what is the exact connection info string for connecting the database. Can anybody help on this ?






1 Answer Found


Answer 1

Firstly you are using CDatabase class, which is strictly ODBC based MFC class.

Your connection  string is effectively:

"ODBC;Provider=MSDASQL;Driver={Microsoft Access Driver (*.mdb, *.accdb)};UID=NULL;PWD=NULL;dbq=C:\\TestDB\\TestDatabase.mdb"

You don't need this token, since it only applies to OLEDB:


You also don't need UID and PWD for Access, unless your user and password are NULL (which makes no sense).  If they are really blank, you would say:  UID=;PWD=;

Hence this is minimal connection string:

"ODBC;Driver={Microsoft Access Driver (*.mdb, ,.accdb)};dbq=C:\\TestDB\\TestDatabase.mdb"




How do we convert, the following code to query a SQL database with ASP using a DSN-less connection


<%@ Page Language="vb" %>
  <script runat="server">
         Dim Name As String
         Sub btnSubmit_Click(sender As Object, e As EventArgs)
            Name = txtHello.Text
            lblHello.Visible = True
         End Sub
  <asp:label id="lblHello" visible="false" runat="server">
         Hello, <%# Name %>!
  <form runat="server">
   <asp:textbox text="" id="txtHello" runat="server" />
   <asp:button text="Submit" id="btnSubmit" OnClick="btnSubmit_Click" runat="server" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DB_13299_applicationConnectionString %>" 
            SelectCommand="SELECT [lblHello]">



We have a process that does value confirmation from a third-party process.  That process returns the value already formatted so we have to format ours and then do a match.  This was working just fine until recently, so I'm wondering if some type of Microsoft update introduced a bug.

I have the following double value which needs to be formatted for currency:



I use this to format it:

doubleObject.ToString("C2", Thread.CurrentThread.CurrentUICulture)


The formatted result is incorrect as it should show .23 cents:



I tried different formats like {0:d} or {0:c2} or {0:#,###,#00.00} and so on and all give the same result.  I also tried the Math.Round function and it's behaving strangely.  When I used it to round to 1 decimal, it worked correctly and I got .2.  But when I used 2 decimal places, it came back with 3, i.e., .234.  I could not get it to come back with 2 decimal places at all.


It's critical for us to have correct values as a result of basic formatting.


I have a bound data field, a detailsview, one of the records I have formatted to currency in the item template. Yet when I go to delete a record, I get a error message "Input string was not in correct format". Take away the formatting and the page runs fine. I tried changing the datatype from int to money, it makes no difference. Ideas? 



I’m getting string alignment issue.

This is my code


String.Format("{0,-108} {1,4} {2,7} {3,7}", productName[x] qtyArray[x], (SubPriceArray[x]).ToString("F2"), TotalPriceArray[x].ToString("F2"))), addressFont, Brushes.Black, 30, m);


I’m getting alignment issue when the “productName” exceeds the 13 characters. My product name should be 50 characters.

 Plz tell me how to do the alignment with the product name with 50 characters.


Wanted to add a new connection soon after creating a form project. Did Add New Data Source...Database...Dataset. At Choose Your Data Connection screen, clicked on New Connection... Screen simply returns and behaves  like Cancel.

I am working on a project for myself. It is in Vs 2010 with SQL Express (on local machine) and a winform application. I am trying to get a good understanding of the connection string and the open object. So I have a general question. I need to be able to connect to the database to fill the controls on the form and take the value of the controls and write to the database. I do understand how to fill the data object. So I just need to get a good understand on the connection string and opening it.  


I use .NET reflector to view the disasembled code of the methods in String class.  Interestingly, I find the String.Equals(string, string) and String.op_Equality(string, string) calls each other, and to my knowledge, this would lead to a StackOverflowException. Here is the code from .NET reflector:

publicstaticbooloperator==(string a, string b)
  returnEquals(a, b);
publicstaticboolEquals(string a, string b)
  return ((a == b) || (((a != null) && (b != null)) && EqualsHelper(a, b)));
Can someone explain why it works?

This is HALF answered in the MSDN library with an example function called IsValidEmail.

Does anyone else think maybe it's time the example function (which developers are likely to copy-paste) was changed to closer represented what an email address can actually be?

Sure, it matches joe.blogs@example.com, or joe-blogs@example.com...

But how about joe.blogs+work@example.com, or joe.blogs+support@example.com, or e=mc^2@example.com, or many other valid email addresses?

The page http://msdn.microsoft.com/en-us/library/01escwtf.aspx has been updated for each new release of VisualStudio/.NET, but even the VS 2010/.NET4.0 one isn't much better!

Hi All,

string sContent = " Some Text, ABC text "+

                          " some ";

When I bind sContent to gridview, it shows a continues line (Some Text, ABC text some)instead of actuall format of the string.

how to display it in actuall format..


Hi, I'm having an issue with String.Format, can somebody tell me if it's something I'm doing.

I'm using C# 2.0 I have code which looks a little bit like this:

Code Snippet

string result;

float floatToConvert = 10780503.000000f;

result = String.Format("{0:0,0}",floatToConvert);

Now I would expect result to have a value of "10,780,503" after this line of code, but it doesn't it has a value of "10,780,500"...

If however I do this:

Code Snippet

string result;

float floatToConvert = 10780503.000000f;

double doubleToConvert = (double)floatToConvert;

result = String.Format("{0:0,0}",doubleToConvert);

result has the correct value of "10,780,503" now.

This is pretty much the gist of things only the float value I'm getting is from a database. Why does it randomly round the value down when doing a String.Format on a float? It's only this value as other values that I'm converting (also from float) don't round themselves down although they are of a lesser magnitude.

I've tried using String.Format("{0:n}",floatToConvert); and I get the same problem, I can think of several ways to work around it but I'd rather it just worked.

Any ideas? 



    I tried to retrieve data in timestamp data type (sql server 2000) into CLongBinary and then convert it into Cstring.  But i got an empty string.  Just to check with you all whether it is possible to reteieve data in timestamp format into string


When trying to extend an existing SharePoint 2010 web application, I get an error. The Web App is running Claims Authentication. I disabled NTLM Auth on the Default Zone - we want the public (default) zone to be Claims / FBA only. We need to expand the web app to make a new zone to enable Search (requires NTLM Auth).

ERROR: System.FormatException: 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.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at Microsoft.SharePoint.Administration.SPIisWebSite.Lookup(Uri uri, Boolean requireHighMatchLevel, Int32& instanceId) at Microsoft.SharePoint.Administration.SPProvisioningAssistant.StopSitesWithMatchingBindings(SPIisSettings settings) at Microsoft.SharePoint.Administration.SPProvisioningAssistant.ProvisionWebApplication(String webApplicationName, String applicationPoolName, SPIisSettings[] settings, Boolean adminWebApp) at Microsoft.SharePoint.Administration.SPWebApplication.ProvisionIisWebSi... 8da4ec82-1802-48c3-b595-21a968db9718 06/29/2010 13:24:27.32* w3wp.exe (0x103C) 0x1364 SharePoint Foundation Runtime tkau Unexpected ...tesAsAdministrator() at Microsoft.SharePoint.Administration.SPWebApplication.ProvisionIisWebSites() at Microsoft.SharePoint.Administration.SPWebApplication.Provision() at Microsoft.SharePoint.ApplicationPages.ExtendWebFarmPage.BtnSubmit_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.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 8da4ec82-1802-48c3-b595-21a968db9718



I'm trying to create a Where expression to filter between two dates, but both dates and the one in the object are in string format (DD/mm/YYYY). My problem is that I'm not able to make the conversion in order to be able to do the comparison. I tried this:



 attribute = Expression.Property(paramExpr, _properties[property]);
 leftExpression = Expression.Convert(attribute, typeof

whereExpr = Expression.And(whereExpr, Expression.GreaterThanOrEqual(leftExpression, 
Expression.Constant(Convert.ToDateTime(values[0]), typeof (DateTime)))); whereExpr = Expression.And(whereExpr, Expression.LessThanOrEqual(leftExpression,
Expression.Constant(Convert.ToDateTime(values[1]), typeof (DateTime))));


values[0] and values[1] are the string dates to compare with. The second line throws an exception:

No coercion operator is defined between types 'System.String' and 'System.DateTime'.

Another option would be converting those strings to a numeric comparable format (YYYYmmDD), but I can't find a way to do it.

Any ideas? Thanks!





I doing some maintenance work on a vb .net web app and receive a system.formatexception input string was not in a correct format error after I update a row from a GridView control.  The database update returns fine and I’ve stepped through the code and it never throws an error but when execution finishes and returns to the browser I get the following.  I turned on the feature to break when an exception occurs but it never does break.


Any suggestions?





Input string was not in a correct format.

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:

[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7469351
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
   System.String.System.IConvertible.ToInt32(IFormatProvider provider) +46
   System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +297
   System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +141
   System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean ignoreNullableTypeChanges) +63
   System.Web.UI.WebControls.ObjectDataSourceView.MergeDictionaries(ParameterCollection reference, IDictionary source, IDictionary destination, String parameterNameFormatString) +423
   System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +850
   System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +92
   System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +907
   System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +704
   System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +123
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3614



I have a float value like 6.245632 and I want to convert it to String with a specific format like 6.24. How can I do so? I tried this but I don't know how to use the format with it:

String^ str;

float f=6.245632;

str = Convert::ToString(f);




I have 2 Columns on two different tables with a Varchar(50). When I am getting the strange resuts, when I compare these two results.


SELECT M.WIVersion,I.IBuild,COUNT(*)    FROM dbo.IP I










 I am getting the result set that, lesser version is greater than higher version.


Can I any one help me to fix this issue.









When TBB.Text = string.Format("{0:#,0.00######}", decimal.Parse(TBB.Text));, how can i change it as none format ? I use textbox at column of datagridview1. So when tbb.text focus on money, it should have string.Format("{0:#,0.00######}", decimal.Parse(TBB.Text));, But when tbb.text focus on name, it should have no string.Format("{0:#,0.00######}", decimal.Parse(TBB.Text));, .




Hi All

I've created a custom ribbon for an excel project with edit boxes used to both input values and display summary results on the ribbon.

I'm having trouble formatting the string displayed in the edit boxes as currency. I have tried to use the String.Format method for the variable populating the edit box but the the editbox continues to display an unformatted number. Below is the code I have tried. Am I approaching this from the wrong way- should I be trying to format the actual text property of the edit box instead of the variable populating it?


privatevoid revCalc()
      var sheet = (Microsoft.Office.Interop.Excel.Worksheet)Globals.ThisWorkbook.Application.Sheets["Sheet1"]; 
      var range2 = sheet.get_Range("revenue", Type.Missing);
      string revCur = String.Format("{0:C}", range2.Value2.ToString());
      ebRev.Text = revCur;




I get the following error code:

 Exception: System.FormatException: Input string was not in a correct format. at System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)

when I try and read xml files.


I use the following code:




                XmlTextReader textReader = new XmlTextReader(filePath);



                while (textReader.Read())


                    if (textReader.IsStartElement())


                        switch (textReader.Name)


                            case "Blacklisted":

                                string xBlacklist = textReader["X"];

                                string yBlacklist = textReader["Y"];

                                string zBlacklist = textReader["Z"];



                                var Blackl = new Blacklist() { Z = Convert.ToSingle(zBlacklist), Y = Convert.ToSingle(yBlacklist), X = Convert.ToSingle(xBlacklist) };

                                BList.Add(_i, Blackl);










I shortened the code a bit to save space.  All variables used are declared etc.


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure