TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
teoman
NA
1
0
problem using a function for several tablenames
Oct 30 2005 7:38 PM
ok.. i have a function and it looks like this..
public static void test(ListBox lst,string tablename)
{
string myConn = "Server
=(local);Integrated security
=SSPI;database=halkdanis";
string str = "SELECT * FROM '"+tablename+"'"; SqlDataAdapter dataAdapter = new SqlDataAdapter(str,myConn);
DataSet dt = new DataSet();
DataAdapter.Fill(dt,tablename); // here it says error
DataTable dtb = dt.Tables[0];
foreach(DataRow dtr in dtb.Rows)
{
lst.Items.Add(dtr["username"]);
}
}
as u can see, i want to get data from mssql
, and put the usernames in a listbox and i want to use this function several times depends on tablenames but it gives error at
DataAdapter.Fill(dt,tablename) ;
i guess its coz of `"` char or dunno what is it..
any help would be great..
thx.
good coding..
Reply
Answers (
1
)
Problem Inserting with CommandBuilder
Reading Excel using ADO.NET