|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: |
*****************************************************
vabEditTables.aspx.cs
*****************************************************
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Drawing;
using System.Data.OleDb;
using ASPEnterpriseManager;
namespace ASPEnterpriseManager.Pages
{
public partial class vabEditTables : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label TableOwner;
protected System.Web.UI.WebControls.Label DateCreated;
protected System.Web.UI.WebControls.ImageButton DropTable;
//Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater
protected System.Web.UI.WebControls.Repeater Repeater2;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
// initiate variables etc
public DataView Source;
public DataSet Ds;
protected void Page_Load(object sender, System.EventArgs e)
{
HttpContext _Context = HttpContext.Current;
if (!Page.IsPostBack)
{
//Response.Write("1#" + Session("connStringCatalog") + "#")
try
{
int X = 0;
int Y = 0;
ASPEnterpriseManager.Server Server = new ASPEnterpriseManager.Server();
ASPEnterpriseManager.Database Database = null;
Server.LoadDatabases();
//If ConnectionString.InitialCatalog <> "" Then
Database = new ASPEnterpriseManager.Database();
Database.LoadObjects();
Session["Database"] = Database;
//End If
Session["Server"] = Server;
//if (Session["postPage"] == 1)
//{
Response.Write("<table style='font-size:xx-small'><tr><td> Database: ");
for (X = 0; X < Server.Databases.Count; X++)
{
Response.Write("<a href='vabsetDatabase.aspx?Catalog=" + Server.Databases[X] + "'" + "target='iFrameHeader' >" + Server.Databases[X] + "</a> ");
}
Response.Write("</td></tr></table>");
//}
//****************************************************************
BindGrid();
//****************************************************************
}
catch
{
//Response.Write("<script language=\"Javascript\">" + System.Environment.NewLine + "parent.location.href='defaultIndex.aspx?Error=Login Failed';" + System.Environment.NewLine + "</" + "script>");
}
//BindGrid();
}
if (Page.IsPostBack)
{
}
Repeater1.DataSource = ((ASPEnterpriseManager.Database)Session["Database"]).Tables;
Repeater1.DataBind();
//hashtable
}
public void BindGrid()
{
//****************************************************************
// Define data objects
//if (Session["postPage"] == 2)
//{
System.Data.SqlClient.SqlConnection Conn = new System.Data.SqlClient.SqlConnection(Session["connStringValue"].ToString());
//Response.Write("2#" + Session("connStringValue") + "#" + "<br/>")
Conn.Open();
System.Data.SqlClient.SqlCommand comm = null;
System.Data.SqlClient.SqlDataReader reader1 = null;
//int Y = 0;
//int X = 0;
bool First = false;
string sqlstmt = null;
comm = new System.Data.SqlClient.SqlCommand("SP_Columns '" + Request["table"] + "'", Conn);
reader1 = comm.ExecuteReader();
Hashtable TypeTable = new Hashtable();
object[] array = new object[101];
var counter = 0;
while (reader1.Read())
{
TypeTable.Add(reader1["Column_Name"], reader1["Type_Name"]);
array[counter] = reader1["Column_Name"];
counter += 1;
}
reader1.Close();
if (Request["sqlstmt"] != "")
{
sqlstmt = Request["sqlstmt"];
//Response.Write("1#" + sqlstmt + "#" + "<br/>");
string sqlColumn1 = null;
sqlColumn1 = array[0].ToString();
sqlstmt = "Select " + "*" + " from [" + Request["table"] + "]";
//Response.Write("2#" + sqlstmt + "#" + "<br/>")
System.Data.SqlClient.SqlConnection con = null;
System.Data.DataSet dataSet1 = new System.Data.DataSet();
System.Data.SqlClient.SqlDataAdapter adapter1 = null;
string sqlTable = null;
//Dim dataRow As Data.DataRow
System.Data.SqlClient.SqlCommandBuilder commandBuilder = null;
string vbconnectionString = Session["connStringValue"].ToString();
con = new System.Data.SqlClient.SqlConnection(vbconnectionString);
adapter1 = new System.Data.SqlClient.SqlDataAdapter(sqlstmt, con);
sqlTable = Request["table"];
Session["connStringTable"] = sqlTable;
adapter1.Fill(dataSet1, "sqlTable");
commandBuilder = new System.Data.SqlClient.SqlCommandBuilder(adapter1);
adapter1.Update(dataSet1.Tables["sqlTable"]);
grid.DataKeyNames = new string[] { sqlColumn1 };
grid.DataSource = dataSet1.Tables["sqlTable"].DefaultView;
grid.DataBind();
//tableGrid.DataSource = dataSet1
//tableGrid.DataBind()
}
else if (Request["Table"] != "")
{
Response.Write("4#" + sqlstmt + "#" + "<br/>");
}
//}
//****************************************************************
//Dim dataSet1 As New DataSet
//Dim adapter1 As SqlDataAdapter
// Read the connection string from Web.config
//Dim connectionString As String = ConfigurationManager.ConnectionStrings("ianwebb").ConnectionString
// Initialize connection
//Conn = New SqlConnection(connectionString)
// Create command
// comm = New SqlCommand("SELECT EmployeeID, Name, City, State, MobilePhone " & "FROM Employees", conn)
//adapter1 = New SqlDataAdapter("SELECT * " & "FROM Employees", Conn)
// Enclose database code in Try-Catch-Finally
//Try
// Open the connection
//conn.Open()
// Execute the command
//reader = comm.ExecuteReader()
// Fill the grid with data
//grid.DataSource = reader
//grid.DataKeyNames = New String() {"EmployeeID"}
//grid.DataBind()
// Close the reader
//reader.Close()
//Finally
// Close the connection
//conn.Close()
//End Try
//adapter1.Fill(dataSet1, "Employees")
//grid.DataSource = dataSet1
//grid.DataKeyNames = New String() {"EmployeeID"}
//grid.DataBind()
//****************************************************************
}
protected void grid_SelectedIndexChanged(object sender, System.EventArgs e)
{
BindDetails();
}
protected void empDetails_PageIndexChanging(object sender, System.Web.UI.WebControls.DetailsViewPageEventArgs e)
{
}
protected void empDetails_ModeChanging(object sender, System.Web.UI.WebControls.DetailsViewModeEventArgs e)
{
empDetails.ChangeMode(e.NewMode);
BindDetails();
}
protected void empDetails_ItemUpdating(object sender, System.Web.UI.WebControls.DetailsViewUpdateEventArgs e)
{
//int employeeId = empDetails.DataKey.Value;
empDetails.ChangeMode(DetailsViewMode.ReadOnly);
BindGrid();
BindDetails();
}
protected void empDetails_ItemUpdated(object sender, System.Web.UI.WebControls.DetailsViewUpdatedEventArgs e)
{
grid.DataBind();
}
public void BindDetails()
{
// Define data objects
System.Data.SqlClient.SqlConnection Conn2 = new System.Data.SqlClient.SqlConnection(Session["connStringValue"].ToString());
//Response.Write("1#" & Session("connStringValue") & "#" & "<br/>")
Conn2.Open();
System.Data.SqlClient.SqlCommand comm2 = null;
System.Data.SqlClient.SqlDataReader reader2 = null;
int Y = 0;
int X = 0;
bool First = false;
string sqlstmt = null;
comm2 = new System.Data.SqlClient.SqlCommand("SP_Columns '" + Request["table"] + "'", Conn2);
reader2 = comm2.ExecuteReader();
Hashtable TypeTable2 = new Hashtable();
object[] array2 = new object[101];
var counter = 0;
while (reader2.Read())
{
TypeTable2.Add(reader2["Column_Name"], reader2["Type_Name"]);
array2[counter] = reader2["Column_Name"];
counter += 1;
}
reader2.Close();
string sqlstmtWhere = null;
string sqlColumn2 = null;
if (Request["sqlstmt"] != "")
{
sqlstmt = Request["sqlstmt"];
Response.Write("1#" + sqlstmt + "#" + "<br/>");
}
else if (Request["Table"] != "")
{
sqlColumn2 = array2[0].ToString();
sqlstmt = "Select " + "*" + " from [" + Request["table"] + "]";
sqlstmt = sqlstmt + " WHERE " + sqlColumn2 + "=@" + sqlColumn2;
//Response.Write("2#" + sqlstmt + "#" & "<br/>")
}
// Obtain the index of the selected row
int selectedRowIndex = grid.SelectedIndex;
// Read the ID
int empId = grid.DataKeys[selectedRowIndex].Value;
// Define data objects
DataSet dataSet2 = new DataSet();
SqlDataAdapter adapter2 = null;
// Read the connection string from Web.config
//Dim connectionString As String = ConfigurationManager.ConnectionStrings("ianwebb").ConnectionString
// Initialize connection
string vbconnectionString2 = Session["connStringValue"].ToString();
Conn2 = new System.Data.SqlClient.SqlConnection(vbconnectionString2);
// Create command
//comm2 = New SqlCommand(sqlstmt & "WHERE " & sqlColumn2 & "=@" & sqlColumn2, Conn2)
comm2 = new SqlCommand(sqlstmt, Conn2);
//adapter2 = New SqlDataAdapter("SELECT * FROM Employees " & "WHERE EmployeeID=@EmployeeID", conn2)
// Add the EmployeeID parameter
comm2.Parameters.Add(sqlColumn2, System.Data.SqlDbType.Int);
comm2.Parameters[sqlColumn2].Value = empId;
//comm2.Parameters[sqlColumn2].Value = dataSet2;
// Enclose database code in Try-Catch-Finally
try
{
// Open the connection
Conn2.Open();
// Execute the command
reader2 = comm2.ExecuteReader();
// Fill the grid with data
empDetails.DataSource = reader2;
empDetails.DataKeyNames = new string[] { sqlColumn2 };
empDetails.DataBind();
// Close the reader
reader2.Close();
}
finally
{
// Close the connection
Conn2.Close();
}
//adapter2.Fill(dataSet2, "sqlColumn2")
//empDetails.DataSource = dataSet2
//empDetails.DataKeyNames = New String() {"sqlColumn2"}
//empDetails.DataBind()
}
override protected void OnInit(EventArgs e)
{
base.OnInit(e);
//INSTANT C# NOTE: Converted event handler wireups:
this.Load += new System.EventHandler(Page_Load);
grid.SelectedIndexChanged += new System.EventHandler(grid_SelectedIndexChanged);
empDetails.PageIndexChanging += new System.Web.UI.WebControls.DetailsViewPageEventHandler(empDetails_PageIndexChanging);
empDetails.ModeChanging += new System.Web.UI.WebControls.DetailsViewModeEventHandler(empDetails_ModeChanging);
empDetails.ItemUpdating += new System.Web.UI.WebControls.DetailsViewUpdateEventHandler(empDetails_ItemUpdating);
empDetails.ItemUpdated += new System.Web.UI.WebControls.DetailsViewUpdatedEventHandler(empDetails_ItemUpdated);
}
}
}
*****************************************************
vabEditTables.aspx
*****************************************************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="vabedittables.aspx.cs" Inherits="ASPEnterpriseManager.Pages.vabEditTables" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="ASPEnterpriseManager"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body style="background-image: url(./images/WebFront.jpg); background-repeat:repeat-x">
<!--START PAGE SECTION-->
<table id="table1" style="z-index:101; position:absolute; top:10px; left:5px; width:auto">
<tr>
<td>
<div style="width:900px; height:570px; font-size:xx-small; overflow:auto; border: 0px solid #000000" id="DIV1" onclick="return DIV1_onclick()">
<% //If Session["postPage"] = 2 Then%>
Tables:
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<a href="vabEditTables.aspx?table=<%# DataBinder.Eval(Container.DataItem, "ObjectName")%>">
<%# DataBinder.Eval(Container.DataItem, "ObjectName")%></a>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
<%//End If;%>
<br />
<%
Session["connStringCatalog"] = ConnectionString.InitialCatalog;
Session["connStringValue"] = ConnectionString.Value;
%>
Heading:2:#<br /><%Response.Write("Cat:" + Session["connStringCatalog"]);%>#<br />
#<% Response.Write("Val:" + Session["connStringValue"]);%>#<br />
#<% Response.Write("Tab:" + Session["connStringTable"]);%>#<br />
#<% Response.Write("Pag:" + Session["postPage"]);%>#
<br />
<form id="form1" runat="server">
<asp:GridView id="grid" runat="server"
AutoGenerateColumns="True"
DataKeyNames="<%=sqlColumn2%>">
<Columns>
<asp:ButtonField CommandName="Select" Text="Select" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
<br />
<asp:DetailsView id="empDetails" runat="server"
AutoGenerateRows="True"
DataKeyNames="<%=sqlColumn2%>">
<Fields>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True"
ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
</form>
</div>
</td>
</tr>
</table>
<!--END PAGE SECTION CODE-->
</body>
</html>
|
Advertisement
| Hall of Fame |