[ milanvla @ 28.09.2005. 23:57 ] @
ovako slicnu temu sam vec postavljao ali nisam nasao odgovor? ovaj asp code iscita sadrzaj tabele u access bazi baza.asp Code: <table> <% Dim conn,rs Set conn= Server.Createobject("ADODB.Connection") Set rs=Server.Createobject("ADODB.Recordset") Set rs1=Server.Createobject("ADODB.Recordset") filePath = Server.MapPath("data.mdb") Conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +filePath) Rs.open "Select FName, LName from people",Conn,3,1 Do while Rs.Eof=False %> <tr> <td><%=(rs("FName"))%></td> <td><%=(rs("LName"))%></td> </tr> <% Rs.movenext Loop Rs.Close Conn.Close %> </table> dok ovaj aspx se cudno ponasa uopste ne prikazuje nista da ima u bazi i jos cudnije ne reaguje ako menjam putanju u connection stringu, cak i kada stavljam neke gluposti evo coda: baza.aspx Code: <%@ Page language="c#" Codebehind="baza.aspx.cs" %> <HTML> <HEAD> <title>WebForm1</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> </HEAD> <body> <form id="Form1" method="post" runat="server"> <asp:datagrid id="DataGrid1" runat="server" PageSize="40" AllowPaging="True" AutoGenerateColumns="False" BackColor="#404040" BorderColor="Black" BorderStyle="Solid" Font-Names="Arial" AllowCustomPaging="True" BorderWidth="1px" CellPadding="0" Width="376px" ForeColor="White" GridLines="Horizontal"> <Columns> <asp:BoundColumn DataField="FName" SortExpression="firstname" HeaderText="First Name"></asp:BoundColumn> <asp:BoundColumn DataField="LName" SortExpression="lastname" HeaderText="Last Name"></asp:BoundColumn> </Columns> </asp:datagrid></form> </body> </HTML> baza.aspx.cs Code: using System; using System.Configuration; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Data.OleDb; using System.Data.Odbc; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace Test { /// <summary> /// Summary description for WebForm1. /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid DataGrid1; #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Page_Load(object sender, System.EventArgs e) { string filePath = Server.MapPath("data.mdb"); string conString = ""PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + filePath; OleDbConnection con=null; OleDbDataAdapter dAdapter = null; DataSet dSet = null; con =new OleDbConnection(conString); con.Open(); string SQL = "select FName,LName from people"; OleDbCommand cmd = new OleDbCommand(SQL,con); dAdapter = new OleDbDataAdapter(cmd); dSet = new DataSet("people"); dAdapter.SelectCommand = new OleDbCommand("select FName,LName from people", con); dAdapter.Fill(dSet,"Employees"); DataGrid1.DataSource = dSet; DataGrid1.DataBind(); dAdapter.Dispose(); con.Close(); } } } kod mene u localu sve radi super, ali an serveru ne. ima li ko ideju zasto nece? da li treba jos nesto da prebacim na server sem aspx i aspx.cs fajla? hvala |