sqldatasource

How to get sqlserver database name from datasource name in Java

女生的网名这么多〃 提交于 2019-12-02 08:48:18
As specified in the title, I want to get the database name in sqlserver, all info I know is datasource name, login name/password to get the Connection object, please show some pointers on how to retrieve the database name correctly, in java, thanks! Even Obtain an instance of java.sql.DatabaseMetaData from the connection object. The names of database can be obtained via getCatalogs() or getSchemas() method (It depends upon the vendor of JDBC driver). ResultSet rs=cn.getMetaData().getSchemas(); while(rs.next()) { System.out.println(rs.getString(1)); } Or use Connection.getCatalog() or

Using C# SQL Parameterization on Column Names

雨燕双飞 提交于 2019-12-02 08:27:12
I'm having a problem. I want this to work, but it doesn't: SqlDataSource.SelectCommand = "SELECT blah1, blah2 FROM myTable WHERE @ColumnName = @Value"; SqlDataSource.SelectParameters.Add("ColumnName", System.Data.DbType.String, "one"); SqlDataSource.SelectParameters.Add("Value", System.Data.DbType.String, "two"); It won't substitue the first paramter "ColumnName." If I remove that parameter and place the column name in it like this, it will work: SqlDataSource.SelectCommand = "SELECT blah1, blah2 FROM myTable WHERE one = @Value"; SqlDataSource.SelectParameters.Add("Value", System.Data.DbType

How to generate the needed SQL statements to Update, Insert, Delete data in GridView?

你说的曾经没有我的故事 提交于 2019-12-02 07:21:52
I'm using GridView along with SqlDataSource , for selecting , updating and deleting , and DetailsView for Inserting , the problem is, when I click one of these buttons, I get this error for the Delete order (and the same error with Insert and Update ..): Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified. it is very exhausting to add these statements myself, and in some cases I need to define stored procedures. I'm asking because I read(but not remember where, unfortunately) a tutorial, which Visual Studio generate all these automatically. source code:

How to generate the needed SQL statements to Update, Insert, Delete data in GridView?

旧时模样 提交于 2019-12-02 07:11:32
问题 I'm using GridView along with SqlDataSource , for selecting , updating and deleting , and DetailsView for Inserting , the problem is, when I click one of these buttons, I get this error for the Delete order (and the same error with Insert and Update ..): Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified. it is very exhausting to add these statements myself, and in some cases I need to define stored procedures. I'm asking because I read(but not

SQLDatasource parameters

半腔热情 提交于 2019-12-02 00:12:18
问题 How can i set sql parameters for an sqlDatasource in the code behind? I am trying like this: int id=1; SqlDataSource1.SelectCommand = "SELECT * FROM categ WHERE id=@id"; SqlDataSourceArticole.SelectParameters.Add("@id", id); // and also like this: SqlDataSourceArticole.SelectParameters.Add("id", id); but it doesn't work? What am i doing wrong? 回答1: Make sure you add the select parameters before trying to set their default value. i.e. SqlDataSourceArticole.SelectParameters.Add("@id", id);

SQLDatasource parameters

淺唱寂寞╮ 提交于 2019-12-01 20:54:04
How can i set sql parameters for an sqlDatasource in the code behind? I am trying like this: int id=1; SqlDataSource1.SelectCommand = "SELECT * FROM categ WHERE id=@id"; SqlDataSourceArticole.SelectParameters.Add("@id", id); // and also like this: SqlDataSourceArticole.SelectParameters.Add("id", id); but it doesn't work? What am i doing wrong? Make sure you add the select parameters before trying to set their default value. i.e. SqlDataSourceArticole.SelectParameters.Add("@id", id); SqlDataSourceArticole.SelectParameters["id"].DefaultValue = id.ToString(); You can update the value by:

How to sort columns in an ASP.NET GridView if using a custom DataSource?

我是研究僧i 提交于 2019-12-01 20:19:10
问题 I can't get my GridView to enable a user to sort a column of data when I'm using a custom SqlDataSource. I have a GridView in which the code in the ASP reference to it in the HTML is minimal: <asp:GridView id="grid" runat="server" AutoGenerateColumns="False" AllowSorting="True"> </asp:GridView> In the code-behind I attach a dynamically-created SqlDataSource (the columns it contains are not always the same so the SQL used to create it is constructed at runtime). For example: I set up the

How to sort columns in an ASP.NET GridView if using a custom DataSource?

杀马特。学长 韩版系。学妹 提交于 2019-12-01 19:23:41
I can't get my GridView to enable a user to sort a column of data when I'm using a custom SqlDataSource. I have a GridView in which the code in the ASP reference to it in the HTML is minimal: <asp:GridView id="grid" runat="server" AutoGenerateColumns="False" AllowSorting="True"> </asp:GridView> In the code-behind I attach a dynamically-created SqlDataSource (the columns it contains are not always the same so the SQL used to create it is constructed at runtime). For example: I set up the columns... BoundField column = new BoundField(); column.DataField = columnName; column.HeaderText = "Heading

How to get a gridview to show all table rows when no text is entered in a dependent textbox?

喜你入骨 提交于 2019-12-01 11:26:02
问题 The below works correctly and filters my gridview based on the text entered in my textbox. When no text is entered into my textbox I get no results and cannot understand why. MY QUESTION How to get a gridview to show all table rows when no text is entered in the textbox? MSSQL @Search nvarchar(50) SELECT [table].[column] FROM [table] WHERE [table].[column] LIKE '%' + @Search + '%' OR COALESCE(@Search,'') = '' MARKUP <asp:TextBox ID="txtSearch" RunAt="Server" Text=""/> <asp:SqlDataSource ID=

Updating gridview with SqlDataSource in asp.net

▼魔方 西西 提交于 2019-12-01 10:57:20
i want to update the records from the gridview using SqlDataSource , here is what i am doing. below is my gridview markup <asp:GridView ID="grdManageFaculties" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="LocalServerDataSource" AutoGenerateDeleteButton="true" AutoGenerateEditButton="true" Width="100%" OnRowUpdating="grdManageFaculties_RowUpdating"> <Columns> <asp:TemplateField HeaderText="MANAGE"> <ItemTemplate> <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit" Text="Edit"></asp:LinkButton> <asp:LinkButton ID="lnkDelete" runat="server" Text="Delete">