Hello I did build a autocomplete text field for my project:
HTML Coding:
<!-- Autocomplete Function -->
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender" runat="server" CompletionSetCount="10" TargetControlID="input_source"
ServiceMethod="GetCompletionList" CompletionInterval="100" EnableCaching="false" MinimumPrefixLength="1">
</ajaxToolkit:AutoCompleteExtender>
<!--Inputfield Autocomplete-->
<asp:TextBox autocomplete="on" id="input_source" OnTextChanged="input_source_TextChanged" runat ="server" class="form-control" placeholder="Please enter"></asp:TextBox>
Code behind C#:
//Autocomplete Field
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetCompletionList(string prefixText, int count)
{
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = lr_sqlserver;
using (SqlCommand com = new SqlCommand())
{
com.CommandText = "SELECT TOP 5 Source FROM" + " " + selected_table + " " + "WHERE Source like '%' + #Search + '%'";
com.Parameters.AddWithValue("#Search", prefixText);
com.Connection = con;
con.Open();
List<string> suggestions = new List<string>();
using (SqlDataReader sdr = com.ExecuteReader())
{
while (sdr.Read())
{
suggestions.Add(sdr["Source"].ToString());
}
}
con.Close();
return suggestions;
}
}
}
Now I want to call the following function everytime I select a suggestion from the autocomplete function. Is something like this possible?
protected void input_source_TextChanged(object sender, EventArgs e)
{
string source = input_source.Text;
using (
SqlConnection com = new SqlConnection())
{
//SQL Server
com.ConnectionString = lr_sqlserver;
//Conncection establish
com.Open();
//Get SQL Information
SqlCommand select = new SqlCommand("select target from " + selected_table + " where source = #param", com);
select.Parameters.AddWithValue("#param", source);
string result;
result = (string)select.ExecuteScalar();
if (result != null)
{
input_target.Text = result;
}
}
}
You would need to put your TextBox inside an UpdatePanel and on the TextBox set AutoPostBack="True"
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox autocomplete="on" id="input_source" OnTextChanged="input_source_TextChanged" runat ="server" class="form-control" placeholder="Please enter" AutoPostBack="True"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
Related
I'm trying to insert content to my local database from a textbox inside a repeater element, in a post - comment way. So far I've tried looping on all the generated rows to find the specific textbox but I have had no luck, either the insert goes empty, or I get 1 insert per preexisting row, or I get the same value inserted over and over again through different posts.
I finally tried to pass the post id to the itemfinder and it's kind of working, but the "comm_contenido" inserts from the textbox are still going empty to the database.
My question is what it the correct and more direct way to handle these kind of inserts from within a Repeater?.
C#:
protected void Button1_Command(object sender, CommandEventArgs e)
{
string postid = e.CommandArgument.ToString();
string emailcc = Session["EMAIL"].ToString();
string user_id = Session["ID"].ToString();
string usrnom = Session["NOMBRE"].ToString();
string usrfoto = Session["FOTO_URL"].ToString();
//string COMM_CONTENIDO = lblcomm.Text.ToString();
var COMM_fecha = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
TextBox txt2;
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConexionBD"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
int m = Int32.Parse(postid);
txt2 = (TextBox)Repeater_UsrPosts.Items[m].FindControl("txtcomentar");
string txt1 = txt2.Text;
cmd.CommandType = CommandType.Text;
cmd.CommandText = (#"INSERT INTO MIEMBROS_Comments (COMM_USER_ID, COMM_CONTENIDO, COMM_FECHA, COMM_USER_NOMBRE, COMM_USER_FOTO, COMM_POST_ID) VALUES ('"
+ user_id + "','" + txt1 + "','" + COMM_fecha + "','" + usrnom + "','" + usrfoto + "','" + postid + "');");
cmd.Connection = conn;
conn.Open();
int rowsAffected = cmd.ExecuteNonQuery();
}
}
//txtpublica.Text = "";
traerposts();
}
ASP:
<asp:Repeater ID="Repeater_UsrPosts" runat="server" >
<ItemTemplate>
<!-- Post -->
<div class="post clearfix">
<div class="user-block">
<img alt="" src="<%#Eval("post_user_foto")%>" class="img-circle img-bordered-sm" />
<span class="username">
<%#Eval("post_user_nombre") %>
<i class="fa fa-times"></i>
</span>
<span class="description"><%#Eval("post_fecha") %></span>
</div>
<!-- /.user-block -->
<p>
<%#Eval("post_contenido") %>
</p>
<ul class="list-inline">
<li><i class="fa fa-share margin-r-5"></i>Share</li>
<li><i class="fa fa-thumbs-o-up margin-r-5"></i>Like
</li>
<li class="pull-right">
<asp:LinkButton ID="bttnabrircomentarios" runat="server" class="link-black text-sm">
<i class="fa fa-comments-o margin-r-5"></i>Comments</asp:LinkButton>
</li>
</ul>
<asp:TextBox ID="txtcomentar" runat="server" class="form-control input-sm" placeholder="Escribe un comentario" EnableViewState="False"></asp:TextBox>
<%# Eval("post_id") %> -
<asp:Button ID="Button1" runat="server" Text="Button"
OnCommand="Button1_Command" CommandName="myCommand"
CommandArgument='<%# Eval("post_ID") %>' />
<br />
</div>
<!-- /.post -->
</ItemTemplate>
</asp:Repeater>
You can reach the TextBox Control by assigning OnTextChanged to it, and you can also assign its AutoPostBack to true if you wanted to reach the data immediately.
but you should use if(!IsPostBack) before you bind your data to your repeater, so it doesn't reset your Controls before you could reach the data.
OnTextChanged needs two parameter, one of them is the sender object which is calling it, That's your TextBox, something like..
ASP
<asp:Repeater ID="RepeaterExample" runat="server"><ItemTemplate>
<asp:TextBox runat="server" ID="TextBoxExample" AutoPostBack="True" OnTextChanged="TextBoxExample_OnTextChanged"/>
</ItemTemplate></asp:Repeater>
Behind Code
protected void TextBoxExample_OnTextChanged(object sender, EventArgs e)
{
TextBox txt = (TextBox) sender;
//Response.Write(txt.Text);
//or whatever you want to do with it.
}
and if you wanted to use it with Button_OnClick, you should use like a global string you can call later, you can do something like this..
ASP
<asp:Button runat="server" ID="ButtonExample" OnClick="ButtonExample_OnClick"/>
Behind Code
private string text = "";
protected void TextBoxTest_OnTextChanged(object sender, EventArgs e)
{
TextBox txt = (TextBox)sender;
text = txt.Text;
}
protected void ButtonExample_OnClick(object sender, EventArgs e)
{
//Response.Write(text);
}
but the last method will take the value of the last TextBox whose text has changed, unless you add it together like..
text += txt.Text;
Hope, I could help..
This were the changes that worked for me to locate the specific textbox and prevent posting unwanted data.
C#:
protected void Button1_Command(object sender, CommandEventArgs e)
{
string postid = e.CommandArgument.ToString();
string emailcc = Session["EMAIL"].ToString();
string user_id = Session["ID"].ToString();
string usrnom = Session["NOMBRE"].ToString();
string usrfoto = Session["FOTO_URL"].ToString();
var COMM_fecha = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Control s = (Control)sender;
TextBox tb = (TextBox)s.NamingContainer.FindControl("txtcomentar");
tb.ReadOnly = true;
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConexionBD"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
string txt1 = tb.Text;
cmd.CommandType = CommandType.Text;
cmd.CommandText = (#"INSERT INTO MIEMBROS_Comments (COMM_USER_ID, COMM_CONTENIDO, COMM_FECHA, COMM_USER_NOMBRE, COMM_USER_FOTO, COMM_POST_ID) VALUES ('"
+ user_id + "','" + txt1 + "','" + COMM_fecha + "','" + usrnom + "','" + usrfoto + "','" + postid + "');");
cmd.Connection = conn;
conn.Open();
int rowsAffected = cmd.ExecuteNonQuery();
}
}
traerposts();
}
And on the ASP I added the property EnableVIewState="true" to the textbox and also to the repeater.
At last, most important, I added if (!Page.IsPostBack) to the onload event.
And with all this together the comments on each post are being inserted correctly.
So here in my application I have 2 dropdowns, 4 labels and a gridview. The Medication Type drop list here with the text PO Meds is supposed to generate the number you see between the 2 drop lists, then based on that number, pull all of the records in the medications table with that number as an ID. The medications should populate in the dropdown marked Medication. The first time I run the application it pulls up the correct information but if I try changing that information, instead of the medication dropdown refilling with the new query information it just adds it to the medication droplist.
here are my 2 droplist and code:
HTML
<td>
<asp:DropDownList ID="ddlMedType" runat="server" DataSourceID="sdsMedType" DataTextField="MedType" DataValueField="MedType" AutoPostBack="True" OnSelectedIndexChanged="ddlMedType_SelectedIndexChanged" AppendDataBoundItems="True">
<asp:ListItem Selected="True">Select Medication Type</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="sdsMedType" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer2 %>" SelectCommand="SELECT [num], [MedType] FROM [pharm_medication_Type]"></asp:SqlDataSource>
<asp:Label ID="lblMedType" runat="server" Visible="true"/>
</td>
<td>
<asp:DropDownList ID="ddlMedication" runat="server" AppendDataBoundItems="True" AutoPostBack="True" OnSelectedIndexChanged="ddlMedication_SelectedIndexChanged" >
<asp:ListItem Selected="True">Choose A Medication</asp:ListItem>
</asp:DropDownList>
</td>
.CS
protected void ddlMedType_SelectedIndexChanged(object sender, EventArgs e)
{
string strMedType = ddlMedType.SelectedValue;
using (SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer2"].ConnectionString))
{
if (ddlMedType.SelectedValue != "Select Medication Type")
{
SqlCommand cmd1 = new SqlCommand("SELECT [num] from [pharm_medication_Type] where [MedType] = #MedType", conn1);
cmd1.Parameters.AddWithValue("#MedType", strMedType);
conn1.Open();
using (SqlDataReader reader2 = cmd1.ExecuteReader())
{
while (reader2.Read())
{
int strNum = reader2.GetInt32(0);
lblMedType.Text = Convert.ToString(strNum);
}
}
string strMedTypeID = lblMedType.Text;
SqlCommand cmd2 = new SqlCommand("Select [MedType_ID], [MedName] from [pharm_medications] where [MedType_ID] = #MedTypeID", conn1);
cmd2.Parameters.AddWithValue("#MedTypeID", strMedTypeID);
ddlMedication.DataSource = cmd2.ExecuteReader();
lblMedType.Text = string.Empty;
ddlMedication.DataTextField = "MedName";
ddlMedication.DataValueField = "MedName";
ddlMedication.DataBind();
ddlMedType.DataBind();
lblMedType.DataBind();
}
}
}
protected void ddlMedication_SelectedIndexChanged(object sender, EventArgs e)
{
string strMedTypeID = lblMedType.Text;
string strMedName = ddlMedication.SelectedValue;
if (ddlMedication.SelectedValue != "Choose A Medication")
{
using (SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer2"].ConnectionString))
{
SqlCommand cmd1 = new SqlCommand(#"SELECT DISTINCT [num], [MedType_ID], [MedName], [MedMin], [MedMax], [ChargingNumber]
FROM [pharm_medications] WHERE [MedType_ID] = #MedTypeID AND [MedName] = #MedName", conn1);
cmd1.Parameters.AddWithValue("#MedTypeID", strMedTypeID);
cmd1.Parameters.AddWithValue("#MedName", strMedName);
conn1.Open();
using (SqlDataReader reader3 = cmd1.ExecuteReader())
{
while (reader3.Read())
{
int myNum = reader3.GetInt32(0);
int strMyMedTypeID = reader3.GetInt32(1);
string strMyMedName = reader3.GetString(2);
string strMedMin = reader3.GetString(3);
string strMedMax = reader3.GetString(4);
string strChargingNumber = reader3.GetString(5);
lblAutoMin.Text = strMedMin;
lblAutoMax.Text = strMedMax;
lblAutoChargeNum.Text = strChargingNumber;
}
}
}
}
}
I create an autocomplete search box and I get product name and I want to get product photo but I did not do it. There is my code:
<asp:TextBox ID="txtContactsSearch" runat="server" Width="261"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="Search11"
MinimumPrefixLength="1"
CompletionInterval="10"
EnableCaching="false"
CompletionSetCount="10"
TargetControlID="txtContactsSearch"
ID="AutoCompleteExtender1" runat="server" FirstRowSelected = "true">
</cc1:AutoCompleteExtender>
Web Service Code:
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> Search11(string prefixText, int count)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.AppSettings["U"].ToString();
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select Top(10) * from S WITH (NOLOCK) where KeySentences like #SearchText + '%' ";
cmd.Parameters.AddWithValue("#SearchText", prefixText);
cmd.Connection = conn;
conn.Open();
List<string> Search = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
//"<img src='st4.abc.com.tr/img/urun/p_" + sdr["RecID"].ToString()+"_01_01.jpg' />" + " "
Search.Add( sdr["KeySentences "].ToString().Substring(0, 30));
Search.Add("<img style = 'height:30px;width:30px' src = 'st4.abc.com.tr/img/urun/p_"+sdr["RecID"].ToString()+"_01_01.jpg'");
}
}
conn.Close();
return Search;
}
}
}
I can get product name but image is not. It seems:
I want to show only picture not HTML text.I think I use script or something like but I dont know What can I do for this? Thanks for your answers
the required functionality can be achieved by referring the following article
http://www.aspsnippets.com/Articles/Render-images-in-autocomplete-list-of-ASP.Net-AJAX-AutoCompleteExtender.aspx
Hi im wondering if its possible to add a asp button to the code below, the code below adds an image and text from my database to a dynamic div on my asp page:
using System.Data.Odbc;
using System.IO;
public partial class UserProfileWall : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string theUserId = Session["UserID"].ToString();
PopulateWallPosts(theUserId);
}
private void PopulateWallPosts(string userId)
{
using (OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite2; User=root; Password=commando;"))
{
cn.Open();
using (OdbcCommand cmd = new OdbcCommand("SELECT wp.WallPostings, p.PicturePath FROM WallPosting wp LEFT JOIN User u ON u.UserID = wp.UserID LEFT JOIN Pictures p ON p.UserID = u.UserID WHERE wp.UserID=" + userId + " ORDER BY idWallPosting DESC", cn))
{
//("SELECT wp.WallPostings, p.PicturePath FROM WallPosting wp LEFT JOIN [User] u ON u.UserID = wp.UserID LEFT JOIN Pictures p ON p.UserID = u.UserID WHERE UserID=" + userId + " ORDER BY idWallPosting DESC", cn))
using (OdbcDataReader reader = cmd.ExecuteReader())
{
test1.Controls.Clear();
while (reader.Read())
{
System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
div.Attributes["class"] = "test";
//div.Style["float"] = "left";
div.ID = "test";
Image img = new Image();
img.ImageUrl = String.Format("{0}", reader.GetString(1));
// this line needs to be represented in sql syntax
//img.ImageUrl = "~/userdata/2/uploadedimage/batman-for-facebook.jpg";
img.AlternateText = "Test image";
div.Controls.Add(img);
div.Controls.Add(ParseControl(String.Format("   "+"{0}", reader.GetString(0))));
div.Style["clear"] = "both";
test1.Controls.Add(div);
}
}
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string theUserId = Session["UserID"].ToString();
using (OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite2; User=root; Password=commando;"))
{
cn.Open();
using (OdbcCommand cmd = new OdbcCommand("INSERT INTO WallPosting (UserID, Wallpostings) VALUES (" + theUserId + ", '" + TextBox1.Text + "')", cn))
{
cmd.ExecuteNonQuery();
}
}
PopulateWallPosts(theUserId);
}
}
Here is the strange thing tho, if I do manage to add a button similar to the way I have added an image, how would I call that button, for example:
I want to call this button "delete" and add code to delete the text in my database related to that div, but if there is multiple divs(there all named the same div id=test) with text and they all have the same asp button how would I be able to tell the button to only delete the current text(in the db) for the current div??
My database stores the information like so:
Im thinking I would have to use idwallposting but not sure how?
Also to give a visual representation of how it looks it may help aid in the understanding:
My css and asp:
div#test1 {
}
div .test {
width:90%;
z-index:1;
padding:27.5px;
border-top: thin solid #736F6E;
border-bottom: thin solid #736F6E;
color:#ffffff;
margin:0 auto;
white-space: pre;
white-space: pre-wrap;
white-space: pre-line;
word-wrap: break-word;
}
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js" type="text/javascript"></script>
<p>
<asp:TextBox ID="TextBox1" name="TextBox1" runat="server" Rows="3"
Height="47px" Width="638px"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="Post Message" Width="98px"
onclick="Button1_Click" />
</p>
<p>
</p>
<style type="text/css">
img {border-width:0px; width:100px; height:100px;}
</style>
<div id="test1" runat="server" />
</div>
</asp:Content>
Why not give each div a unique ID like div.ID = "test" + idWallPostings; ?
It is not a good idea to have non-unique IDs for any element.
Regarding your main problem, why not use one of the templated data controls like Repeater or ListView and add a Command handler. Then in the template add the button with a command argument for the current data item's data key.
see: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemcommand.aspx
You can see how the the button is used to carry additional information in its click event:
<asp:LinkButton runat="server"
ID="SelectEmployeeButton"
Text="Add To List"
CommandName="AddToList"
CommandArgument='<%#Eval("LastName") + ", " + Eval("FirstName") %>' />
and how it is retrieved and used (it is accessed using e.CommandArgument):
protected void EmployeesListView_OnItemCommand(object sender, ListViewCommandEventArgs e)
{
if (String.Equals(e.CommandName, "AddToList"))
{
// Verify that the employee ID is not already in the list. If not, add the
// employee to the list.
ListViewDataItem dataItem = (ListViewDataItem)e.Item;
string employeeID =
EmployeesListView.DataKeys[dataItem.DisplayIndex].Value.ToString();
if (SelectedEmployeesListBox.Items.FindByValue(employeeID) == null)
{
ListItem item = new ListItem(e.CommandArgument.ToString(), employeeID);
SelectedEmployeesListBox.Items.Add(item);
}
}
}
For deletion from database with C# in Visual Studio 2008 ASP.net write the following code by double-clicking on button:
protected void btndel_Click(object sender, EventArgs e)
{
SqlConnection conn;
SqlCommand cmd;
conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename='C:\\Users\\THEGIRL\\Documents\\Visual Studio 2008\\WebSites\\WebSite72\\App_Data\\Database.mdf';Integrated Security=True;User Instance=True");
conn.Open();
cmd = new SqlCommand("Delete from logintable where username='"+txtdeluname.Text+"'",conn);
lbldel.Text = "Record is deleted";
cmd.ExecuteNonQuery();
conn.Close();
}
Ok I am using the code below in file called autocomplete.asmx (web service file) my main question is do I need to create a different web service for every field I want my auto complete to work for? IE maybe I would like to have the Company Name pulled out instead of country, but another time maybe name, now I know this just involves changing the select statement but How could I go about doing this so that depending on what field it is, it knows what select statement to use?
Thanks
public class AutoComplete : System.Web.Services.WebService
{
[WebMethod]
public string[] GetCountriesList(string prefixText)
{
DataSet dtst = new DataSet();
SqlConnection sqlCon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
string strSql = "SELECT CountryName FROM Tbl_ooo WHERE CountryName LIKE '" + prefixText + "%' ";
SqlCommand sqlComd = new SqlCommand(strSql, sqlCon);
sqlCon.Open();
SqlDataAdapter sqlAdpt = new SqlDataAdapter();
sqlAdpt.SelectCommand = sqlComd;
sqlAdpt.Fill(dtst);
string[] cntName = new string[dtst.Tables[0].Rows.Count];
int i = 0;
try
{
foreach (DataRow rdr in dtst.Tables[0].Rows)
{
cntName.SetValue(rdr["CountryName"].ToString(), i);
i++;
}
}
catch { }
finally
{
sqlCon.Close();
}
return cntName;
}
}
Yes, you can use same webservice webmethod to populate country and company.
For that you want to use ContextKey property in ajax AutoCompleteExtender control
Below is the sample Code
Markup :
Search
<asp:TextBox ID="txtSearch" CssClass="textBlackBold" runat="server" Width="350px"></asp:TextBox>
<asp:DropDownList ID="ddlType" runat="server" AutoPostBack="True" onselectedindexchanged="ddlType_SelectedIndexChanged">
<asp:ListItem Value="0">Country</asp:ListItem>
<asp:ListItem Value="1">Companies</asp:ListItem>
</asp:DropDownList>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
EnableCaching="true" ContextKey="Products" UseContextKey="true"
TargetControlID="txtSearch" MinimumPrefixLength="1"
ServiceMethod="GetInfo" ServicePath="~/WebService.asmx" >
</asp:AutoCompleteExtender>
Code Behind C# Code :
protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
{
string strContextKey = "";
if(ddlType.SelectedValue.ToString() == "0")
strContextKey = "Country";
else
strContextKey = "Companies";
AutoCompleteExtender1.ContextKey = ddlType.SelectedItem.Text;
}
WebService Code :
[WebMethod]
public string[] GetInfo(string prefixText, string contextKey)
{
DataSet dtst = new DataSet();
SqlConnection sqlCon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
string strSql = "";
if (contextKey == "Country")
{
strSql = "SELECT CountryName FROM Tbl_ooo WHERE CountryName LIKE '" + prefixText + "%' ";
}
else if(contextKey == "Companies")
{
strSql = //Other SQL Query
}
SqlCommand sqlComd = new SqlCommand(strSql, sqlCon);
sqlCon.Open();
SqlDataAdapter sqlAdpt = new SqlDataAdapter();
sqlAdpt.SelectCommand = sqlComd;
sqlAdpt.Fill(dtst);
string[] cntName = new string[dtst.Tables[0].Rows.Count];
int i = 0;
try
{
foreach (DataRow rdr in dtst.Tables[0].Rows)
{
cntName.SetValue(rdr[0].ToString(),i);
i++;
}
}
catch { }
finally
{
sqlCon.Close();
}
return cntName;
}