Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 10 của 10
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi ltvit0602
    Bạn vào Database và tạo mới 1 DB mới + Database user xong rồi nếu host có hỗ trợ chức năng attack , restore hay upload db lên thì bạn vào đó làm, nếu ko hỗ trợ bạn pải upload file backup của db lên rồi nhờ bên host họ restore cho sau đó họ cấu hình connectionstring tới db là đc!
    Bạn chú ý
    Đối với host bất kì nào đó
    Để sử dụng csdl
    1. Tạo người dùng -- user
    2. Tạo csdl
    3. Attack csdl - import CSDL ( Nếu cần thiết)
    4. config ( cái này trong source code nhé)
    5. Run

    Chúc bạn thành công [IMG]images/smilies/laughing.gif[/IMG]

  2. #2
    Hic, sao từ ngữ tiếng anh chuyên ngành mà các bạn cứ hùa nhau viết sai vậy kìa. Attach = đính kèm, Attack = tấn công ( nhiễm game chăng ? ). Các bạn viết sai như thế, bạn mới ko biết gì thì sao mà hiểu cho được.

  3. #3
    Ngày tham gia
    Sep 2015
    Đang ở
    Số 60 Thái Hà, Đống Đa, Hà Nội
    Bài viết
    0
    trước tiên tạo csdl trên host, sau đó chỉnh cấu hình server ,csdl trong file web.config

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Cách dùng database trên host thật như thế nào?

    Em muốn làm một vài demo nhỏ nhỏ. để upload lên host thật sử dụng.
    Demo đơn giản là có
    - 1 page update.aspx up một đoạn string lên.
    và một page hiển thị dữ liệu đã được update lên bằng string.

    - Nhưng mò vào host thật của nhân hòa vào mục Database or ODBC thì chịu ko thấy đâu cả. Gói của em là host cho sinh viên thôi.
    Anh nào biết cách dùng database trong asp.net của C# thì bảo em cách config để dùng với.

    Em xin thành thật cảm ơn.

  5. #5
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Bạn vào Database và tạo mới 1 DB mới + Database user xong rồi nếu host có hỗ trợ chức năng attack , restore hay upload db lên thì bạn vào đó làm, nếu ko hỗ trợ bạn pải upload file backup của db lên rồi nhờ bên host họ restore cho sau đó họ cấu hình connectionstring tới db là đc!

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi meoconlongvang
    Hic, sao từ ngữ tiếng anh chuyên ngành mà các bạn cứ hùa nhau viết sai vậy kìa. Attach = đính kèm, Attack = tấn công ( nhiễm game chăng ? ). Các bạn viết sai như thế, bạn mới ko biết gì thì sao mà hiểu cho được.
    Cho mình xin lỗi... hic
    đang học bảo mật.. nên nhiễm [IMG]images/smilies/smile.png[/IMG])[IMG]images/smilies/daydreaming.gif[/IMG]

    Chú ý lần nữa

    ---- NHỚ TẠO USER trước khi làm gì với CSDL (Đối với host có phí nhé -- host free thì.. nó làm cho luôn rồi)

  7. #7
    Trích dẫn Gửi bởi meoconlongvang
    Hic, sao từ ngữ tiếng anh chuyên ngành mà các bạn cứ hùa nhau viết sai vậy kìa. Attach = đính kèm, Attack = tấn công ( nhiễm game chăng ? ). Các bạn viết sai như thế, bạn mới ko biết gì thì sao mà hiểu cho được.
    - Thanks anh.

    Trích dẫn Gửi bởi zstar
    trước tiên tạo csdl trên host, sau đó chỉnh cấu hình server ,csdl trong file web.config
    Hi anh.
    em chỉnh web.config thế này. anh xem đã oke chưa.

    Trích dẫn Gửi bởi tesulakata
    Cho mình xin lỗi... hic
    đang học bảo mật.. nên nhiễm [IMG]images/smilies/smile.png[/IMG])[IMG]images/smilies/daydreaming.gif[/IMG]
    Chú ý lần nữa
    ---- NHỚ TẠO USER trước khi làm gì với CSDL (Đối với host có phí nhé -- host free thì.. nó làm cho luôn rồi)
    Hi anh.
    - host của em là host có phí. Nhưng ko support cho việc chỉnh database. Nên Phải dùng cách up lên và nhờ họ back up rồi. Nếu nhờ như vậy thì có phải tạo user ko. Và tạo user rồi, thì file up lên hoặc trong web có phải chỉnh sửa gì nữa ko.


    Trích dẫn Gửi bởi ltvit0602
    Bạn vào Database và tạo mới 1 DB mới + Database user xong rồi nếu host có hỗ trợ chức năng attack , restore hay upload db lên thì bạn vào đó làm, nếu ko hỗ trợ bạn pải upload file backup của db lên rồi nhờ bên host họ restore cho sau đó họ cấu hình connectionstring tới db là đc!
    thanks anh.

    Demo của em đơn giản thôi:
    Chỉ là một cái dropdownlist tên của khách hàng. Chọn tên ai thì hiển thi hết thông tin của khách hàng vào Gridview bên dưới:

    file Default.aspx

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    Chọn khách hàng
    <asp[IMG]images/smilies/biggrin.png[/IMG]ropDownList ID="ddlCustomers" runat="server" AutoPostBack="True"
    onselectedindexchanged="ddlCustomers_SelectedIndex Changed">
    </asp[IMG]images/smilies/biggrin.png[/IMG]ropDownList>
    <asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="False"
    CellPadding="4" DataKeyNames="OrderID" ForeColor="#333333" GridLines="None">
    <RowStyle BackColor="#EFF3FB" />
    <Columns>
    <asp:BoundField DataField="OrderID" HeaderText="Order ID" InsertVisible="False"
    ReadOnly="True" SortExpression="OrderID">
    <ItemStyle HorizontalAlign="Center" />
    </asp:BoundField>
    <asp:BoundField DataField="CustomerID" HeaderText="Customer ID"
    SortExpression="CustomerID" />
    <asp:BoundField DataField="EmployeeID" HeaderText="Employee ID"
    SortExpression="EmployeeID">
    <ItemStyle HorizontalAlign="Right" />
    </asp:BoundField>
    <asp:BoundField DataField="OrderDate" DataFormatString="{0:dd/MM/yyyy}"
    HeaderText="Order Date" SortExpression="OrderDate">
    <ItemStyle HorizontalAlign="Center" />
    </asp:BoundField>
    <asp:BoundField DataField="RequiredDate" DataFormatString="{0:dd/MM/yyyy}"
    HeaderText="Required Date" SortExpression="RequiredDate">
    <ItemStyle HorizontalAlign="Center" />
    </asp:BoundField>
    <asp:BoundField DataField="ShippedDate" DataFormatString="{0:dd/MM/yyyy}"
    HeaderText="Shipped Date" SortExpression="ShippedDate">
    <ItemStyle HorizontalAlign="Center" />
    </asp:BoundField>
    <asp:BoundField DataField="ShipVia" HeaderText="Ship Via"
    SortExpression="ShipVia">
    <ItemStyle HorizontalAlign="Right" />
    </asp:BoundField>
    <asp:BoundField DataField="Freight" DataFormatString="{0:N2}"
    HeaderText="Freight" SortExpression="Freight">
    <ItemStyle HorizontalAlign="Right" />
    </asp:BoundField>
    <asp:BoundField DataField="ShipName" HeaderText="Ship Name"
    SortExpression="ShipName" />
    <asp:BoundField DataField="ShipAddress" HeaderText="Ship Address"
    SortExpression="ShipAddress" />
    <asp:BoundField DataField="ShipCity" HeaderText="Ship City"
    SortExpression="ShipCity" />
    <asp:BoundField DataField="ShipRegion" HeaderText="Ship Region"
    SortExpression="ShipRegion" />
    <asp:BoundField DataField="ShipPostalCode" HeaderText="Ship Postal Code"
    SortExpression="ShipPostalCode" />
    <asp:BoundField DataField="ShipCountry" HeaderText="Ship Country"
    SortExpression="ShipCountry" />
    </Columns>
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#2461BF" />
    <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    </div>
    </form>
    </body>
    </html>
    và file Default.aspx.cs như sau:

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace WebApplication4
    {
    public partial class _Default : System.Web.UI.Page
    {
    private string cnnString;
    protected void Page_Load(object sender, EventArgs e)
    {
    cnnString = "Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True";
    if (!Page.IsPostBack)
    {
    SqlDataAdapter da = new SqlDataAdapter("Select CustomerID, CompanyName from Customers", cnnString);
    DataTable dt = new DataTable("Customers");
    da.Fill(dt);

    ddlCustomers.DataTextField = "CompanyName";
    ddlCustomers.DataValueField = "CustomerID";
    ddlCustomers.DataSource = dt;
    ddlCustomers.DataBind();
    }
    }

    protected void ddlCustomers_SelectedIndexChanged(object sender, EventArgs e)
    {
    SqlDataAdapter da = new SqlDataAdapter("Select * from Orders Where CustomerID = '" + ddlCustomers.SelectedValue + "'", cnnString);
    DataTable dt = new DataTable("Orders");
    da.Fill(dt);

    gvOrders.AutoGenerateColumns = false;
    gvOrders.DataSource = dt;
    gvOrders.DataBind();
    }
    }
    }
    Em dùng database Northwind kết nối qua SQL 2008 Express. lúc đầu chạy file instnwnd.sql rồi ấn execute nó ra được 2 file là .ldf và file .mdf
    Khi chạy thì chỉ cần kết nối Server Explorer. click click vào [IMG]images/smilies/biggrin.png[/IMG] ở trong visual studio 2008.

    Em dùng host sinh viên, ko hỗ trợ. nên phải up lên và backup lại. Vậy em phải up lên file gì?

    thanks các anh

  8. #8
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    giả sử cấu hình trong web.config có đoạn

    Mã:
    ....<connectionStrings> <add name="zstarConnectString" connectionString="Data Source=192.168.1.15\zstar;Initial Catalog=test;Persist Security Info=True;User ID=sa;Password=123456;"   providerName="System.Data.SqlClient" />   </connectionStrings>....
    tôi sẽ lấy chuỗi kết nối này trong code như sau :

    Mã:
    String zstarConnect= ConfigurationManager.ConnectionStrings["zstarConnectString"].ToString();//lam gi thi lamSqlDataAdapter da = new SqlDataAdapter("Select CustomerID, CompanyName from Customers", zstarConnect);DataTable dt = new DataTable("Customers");da.Fill(dt);
    như vậy khi web published, tôi chỉ cần thay đổi cấu hình trong file web.config là xong
    regards!

  9. #9
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Chào bạn! thứ nhất bạn pải publish web bạn ra 1 thư mục rồi upload tất cả các file trong thư mục publish đó lên host
    (cách publish chuột phải vào thư mục gốc web trên Solution Explorer chọn publish) sau đó bạn mở sqlserver lên và tạo file backup csdl sau đó up lên thư mục nào đó trên host( thư mục gốc trên host đi) thường là thư mục (httpdocs) ko thì up vào thư mục App_Data trên host sau đó alo cho bên host bảo họ restore lại DB và họ cấu hình lại cho là ok! mình ko pải làm cái việc đó nữa! họ khắc làm cho mình [IMG]images/smilies/smile.png[/IMG])

  10. #10
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi zstar
    giả sử cấu hình trong web.config có đoạn

    Mã:
    ....<connectionStrings> <add name="zstarConnectString" connectionString="Data Source=192.168.1.15\zstar;Initial Catalog=test;Persist Security Info=True;User ID=sa;Password=123456;"   providerName="System.Data.SqlClient" />   </connectionStrings>....
    Hehe thanks anh nhiều. Cái này tiện hơn trong việc lập trình. Nhưng em phải add thêm
    using System.Configuration; thì mới dùng đc.
    a rất nhiệt tình với mấy ae gà như em hahaha mấy bài hát ở chữ kí anh rất hay.
    Phạm phương thảo có phải là tên ca sĩ ko ạ.

    tôi sẽ lấy chuỗi kết nối này trong code như sau :

    Mã:
    String zstarConnect= ConfigurationManager.ConnectionStrings["zstarConnectString"].ToString();//lam gi thi lamSqlDataAdapter da = new SqlDataAdapter("Select CustomerID, CompanyName from Customers", zstarConnect);DataTable dt = new DataTable("Customers");da.Fill(dt);
    như vậy khi web published, tôi chỉ cần thay đổi cấu hình trong file web.config là xong
    regards!
    thanks bạn [IMG]images/smilies/smile.png[/IMG]
    Mình thử và đã up lên host rồi [IMG]images/smilies/smile.png[/IMG] Đang chờ xem kết quả.
    Bạn nói thế này dễ hiểu hơn. các sếp nói là backup, backup dữ liệu [IMG]images/smilies/biggrin.png[/IMG] hehe

    giờ cày tiếp asp.net [IMG]images/smilies/smile.png[/IMG]

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •