Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
problem using a function for several tablenames
teoman
19y
2k
1
Reply
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..
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Problem Inserting with CommandBuilder
Reading Excel using ADO.NET