hello
i am trying to insert data to Data base using Stored Proc , while i replace my Connection string in the web.config file
after i run my app , and inserting my data..
it says

Keyword not supported: 'data base'.

Dani AI

Generated

The exception "Keyword not supported: 'data base'." is coming from ADO.NET's connection-string parser — it treats keywords as tokens, so the two-word "Data Base" is not recognized. As suggested, replace that token with a supported keyword (for example Database or Initial Catalog). was right to ask for the web.config; the web.config posted by shows the offending token.

Try one of these canonical forms (replace the database/instance name as needed):

Data Source=.;Database=ContactUsDB;Integrated Security=True;
-- or --
Server=.\SQLEXPRESS;Initial Catalog=ContactUsDB;Trusted_Connection=True;

If changing the token to Database doesn't fix it, follow these quick checks:

  • Make sure you edited the exact web.config that the running site uses (check any Web.Debug.config / Web.Release.config transforms, the deployed web.config, and machine-level connectionStrings).
  • Verify the runtime value by logging it: e.g. print ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString (sanitize before posting). That will show the effective string the app is trying to parse.
  • Ensure the name in <add name="..."> exactly matches the key you use in ConfigurationManager.ConnectionStrings[...].
  • Restart the site after edits to be sure the new config is loaded.

Additional tips: prefer using blocks for SqlConnection/SqlCommand to ensure disposal, confirm the SQL instance name and that the database exists, and avoid pasting credentials into public posts (sanitize if you post the runtime string). If you still see the same error, post the exact runtime string (with sensitive parts redacted) so contributors can spot any remaining malformed token.

Recommended Answers

All 5 Replies

i am trying to attach a screen shoot but i cnt find any tool here to attach with !! ;s

Use the paperclip in the toolbar.

data base should probably be database

when i edited data base to database.. it ddnt work .
it says

Sunday, December 29, 2013 12:43 AM <dir> bin
Wednesday, January 01, 2014 11:57 AM 3,894 ContactUs.aspx
Wednesday, January 01, 2014 12:23 PM 1,902 ContactUs.aspx.cs
Wednesday, January 01, 2014 11:57 AM 5,658 ContactUs.aspx.designer.cs
Sunday, December 29, 2013 12:43 AM 4,256 ContactUs.csproj
Sunday, December 29, 2013 12:43 AM 1,086 ContactUs.csproj.user
Sunday, December 29, 2013 12:04 AM <dir> obj
Sunday, December 29, 2013 12:04 AM <dir> Properties
Wednesday, January 01, 2014 04:11 PM 547 Web.config
Sunday, December 29, 2013 12:04 AM 1,285 Web.Debug.config
Sunday, December 29, 2013 12:04 AM 1,346 Web.Release.config

where is that paper clip ?

Please post your web.config file. Feel free to censor user names, server names, and passwords. It looks like the connection string is malformed for the information you've already provided.

here you are a compy of my web.config file

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <connectionStrings>
    <add
      name="myConnectionString" 
      connectionString=" Data Source=. ; Data Base = ContactUsDB ; Integrated Security = true"
      providerName="System.Data.SqlClient"></add>

  </connectionStrings>
    <system.web>
        <compilation debug="true" targetFramework="4.0" ></compilation>
    </system.web>

</configuration>

and this is my code

 protected void Button1_Click(object sender, EventArgs e)
        {



        string conString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(conString);
        SqlCommand Cmd = new SqlCommand();
        Cmd.CommandType = CommandType.StoredProcedure;
        Cmd.CommandText = "Sp_ContactUs_Insert";


        Cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = TxtName.Text.Trim();
        Cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = TxtEmail.Text.Trim();
        Cmd.Parameters.Add("@Phone", SqlDbType.VarChar).Value = TxtPhone.Text.Trim();
        Cmd.Parameters.Add("@MailSubject", SqlDbType.VarChar).Value = TxtSubject.Text.Trim();
        Cmd.Parameters.Add("@Body", SqlDbType.VarChar).Value = TxtBody.Text.Trim();
        try
        {
        Cmd.Connection = con;

            con.Open();
            if (Cmd.ExecuteNonQuery() > 0)
            {
                Label1.Text = " Your Message Has been Sent , Thank you";
            }
            else
            {
                Label1.Text = " There is an error... please try again later";
            }
        }

        finally
        {
            con.Close();
            con.Dispose();

        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.