?
Solved

programmatically using an sql datasource to bind?

Posted on 2012-09-06
4
Medium Priority
?
588 Views
Last Modified: 2012-09-07
Hi al,

first attempt at this, i think im almost there... the connection string is in the web.config file

        dsGroups.ConnectionString = "DefaultConnection";
        dsGroups.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
        dsGroups.SelectCommand = "sp_tblGroups_Select";

        ddGroups.DataSource = dsGroups;
        ddGroups.DataBind();

Open in new window


error
Format of the initialization string does not conform to specification starting at index 0. 

Open in new window

0
Comment
Question by:awilderbeast
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:Rose Babu
Rose Babu earned 1000 total points
ID: 38373191
Hi,

If you are having the connection string in appSettings tag in web.config, get the connection string as mentioned below
//     web.config

<appSettings>
	<add key="DBConString" value="server=localhost;database=DBNAME;uid=USER;password=PASSWORD;" />
</appSettings>

//     code Behind

using System.Configuration;

string DBConString = ConfigurationSettings.AppSettings("DBConString");

dsGroups.ConnectionString = DBConString;
dsGroups.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
dsGroups.SelectCommand = "sp_tblGroups_Select";

ddGroups.DataSource = dsGroups;
ddGroups.DataBind();

Open in new window

If you are having the connection string in connectionStrings tag in web.config, get the connection string as mentioned below
//     web.config

<connectionStrings>
	<add name="DBConString" connectionString="server=localhost;database=DBNAME;uid=USER;password=PASSWORD;" />
</connectionStrings>

//     code Behind

using System.Configuration;

string DBConString = ConfigurationManager.ConnectionStrings["DBConString"].ConnectionString;

dsGroups.ConnectionString = DBConString;
dsGroups.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
dsGroups.SelectCommand = "sp_tblGroups_Select";

ddGroups.DataSource = dsGroups;
ddGroups.DataBind();

Open in new window

Make sure you have formatted the connection string properly with the correct db credentials.
also check the DB permissions on the SQL server for the user you have used.

http://stackoverflow.com/questions/5219676/format-of-the-initialization-string-does-not-conform-to-specification-starting-a

hope these will help you...
0
 
LVL 1

Author Comment

by:awilderbeast
ID: 38375395
the second one works for me :)

quick one my drop down list is now sayign system.data.dataviewrow instead of the data, how do i bind a column?

for each?
0
 
LVL 7

Accepted Solution

by:
mr_nadger earned 1000 total points
ID: 38375431
off the top of my head there are datatextfield and datavaluefield properties which needs setting - one sets the text to be displayed, the other the value of the selected item (e.g. "Yes" and "y")
0
 
LVL 1

Author Closing Comment

by:awilderbeast
ID: 38375627
Thanks Alot
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question