Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > รันงานไม่ได้ค่ะ c# มันฟ้องแบบนี้ ฟ้องแบบนี้ต้องแก้ไขไงค่ะ Login failed for user ''. The user is not associated with a trusted SQL Server connection.



 

รันงานไม่ได้ค่ะ c# มันฟ้องแบบนี้ ฟ้องแบบนี้ต้องแก้ไขไงค่ะ Login failed for user ''. The user is not associated with a trusted SQL Server connection.

 



Topic : 034743

Guest




ฟ้องแบบนี้ต้องแก้ไขไงค่ะ Login failed for user ''. The user is not associated with a trusted SQL Server connection.
ช่วยแนะนำด้วยค่ะ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-11-23 09:55:31 By : Maklee View : 2279 Reply : 10
 

 

No. 1



โพสกระทู้ ( 179 )
บทความ ( 0 )



สถานะออฟไลน์


กำลังจะต่อ Database หรือเปล่าครับ ?
ลองไปตรวจสอบ ตรงส่วน Connect Database ดูครับ ตรง Datasource ว่ากำหนด User Password ถูกอ่ะเปล่าครับ ^^






Date : 2009-11-23 11:18:10 By : ksillapapan
 


 

No. 2

Guest


ได้กำหนดใน odbc แล้วค่ะ ลองหลายแบบแล้วใส่หรือไม่ใส่ Ps เมื่อสั่งรันก็ยังไม่ได้ค่ะ
Date : 2009-11-23 12:48:39 By : Maklee
 

 

No. 3



โพสกระทู้ ( 179 )
บทความ ( 0 )



สถานะออฟไลน์


คือยัง ConnectDatabase ไม่ได้หรอ ครับ ขอรายละเอียด ส่วนการ Connect หน่อยครับ เดี้ยวจะลองดูให้
Date : 2009-11-24 10:19:13 By : ksillapapan
 


 

No. 4

Guest


ค่ะ นำมาจากตัวอย่างที่ thaicreate ค่ะ แต่พอนำไปแก้เป็นฐานของเราเองไม่สามารถรันได้
ฟ้องแบบนี้ค่ะ The ConnectionString property has not been initialized.

ตัวโค้ด ดังนี้ค่ะ

<%@ Page Language="C#" Debug="true" %>

<script runat="server">
		SqlDataSource myDSource;
		string strSQL;
        //public string strSQL = System.Configuration.ConfigurationManager.ConnectionStrings["compli_test"].ConnectionString;

		void Page_Load(object sender, EventArgs e)
		{
		    
			myDSource = new SqlDataSource();
            myDSource.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
		    
		    if (!Page.IsPostBack) {
		        BindData();
		    }
		}

		void BindData()
		{
		    
		    myDSource.SelectCommand = "SELECT * FROM [customer]";

		    //*** BindData to GridView ***'
		    myGridView.DataSource = myDSource;
		    myGridView.DataBind();
		    
		    myDSource = null;
		    
		}

		void modEditCommand(object sender, GridViewEditEventArgs e)
		{
		    myGridView.EditIndex = e.NewEditIndex;
		    myGridView.ShowFooter = false;
		    BindData();
		}

		void modCancelCommand(object sender, GridViewCancelEditEventArgs e)
		{
		    myGridView.EditIndex = -1;
		    myGridView.ShowFooter = true;
		    BindData();
		}

		void modDeleteCommand(object sender, GridViewDeleteEventArgs e)
		{
		    strSQL = "DELETE FROM customer WHERE CustomerID = '" + myGridView.DataKeys[e.RowIndex].Value + "'";
		    
	        myDSource.DeleteCommand = strSQL;
	        myDSource.DeleteCommandType = SqlDataSourceCommandType.Text;
	        myDSource.Delete();
		    
		    myGridView.EditIndex = -1;
		    BindData();
		}


		void myGridView_RowCommand(object source, GridViewCommandEventArgs e)
		{
		    if (e.CommandName == "Add") {
		        //*** CustomerID ***'
		        TextBox txtCustomerID = (TextBox)myGridView.FooterRow.FindControl("txtAddCustomerID");
		        //*** Email ***'
		        TextBox txtName = (TextBox)myGridView.FooterRow.FindControl("txtAddName");
		        //*** Name ***'
		        TextBox txtEmail = (TextBox)myGridView.FooterRow.FindControl("txtAddEmail");
		        //*** CountryCode ***'
		        TextBox txtCountryCode = (TextBox)myGridView.FooterRow.FindControl("txtAddCountryCode");
		        //*** Budget ***'
		        TextBox txtBudget = (TextBox)myGridView.FooterRow.FindControl("txtAddBudget");
		        //*** Used ***'
		        TextBox txtUsed = (TextBox)myGridView.FooterRow.FindControl("txtAddUsed");
		        
		        strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " + 
				" VALUES ('" + txtCustomerID.Text + "','" + txtName.Text + "','" + txtEmail.Text + "' " + 
				" ,'" + txtCountryCode.Text + "','" + txtBudget.Text + "','" + txtUsed.Text + "') ";
		        
	            myDSource.InsertCommand = strSQL;
	            myDSource.InsertCommandType = SqlDataSourceCommandType.Text;
	            myDSource.Insert();
		        
		        BindData();
		    }
		}


		void modUpdateCommand(object s, GridViewUpdateEventArgs e)
		{
		    
		    //*** CustomerID ***'
		    TextBox txtCustomerID = (TextBox)myGridView.Rows[e.RowIndex].FindControl("txtEditCustomerID");
		    //*** Email ***'
		    TextBox txtName = (TextBox)myGridView.Rows[e.RowIndex].FindControl("txtEditName");
		    //*** Name ***'
		    TextBox txtEmail = (TextBox)myGridView.Rows[e.RowIndex].FindControl("txtEditEmail");
		    //*** CountryCode ***'
		    TextBox txtCountryCode = (TextBox)myGridView.Rows[e.RowIndex].FindControl("txtEditCountryCode");
		    //*** Budget ***'
		    TextBox txtBudget = (TextBox)myGridView.Rows[e.RowIndex].FindControl("txtEditBudget");
		    //*** Used ***'
		    TextBox txtUsed = (TextBox)myGridView.Rows[e.RowIndex].FindControl("txtEditUsed");
		    
		    strSQL = "UPDATE customer SET CustomerID = '" + txtCustomerID.Text + "' " + 
			" ,Name = '" + txtName.Text + "' " + " ,Email = '" + txtEmail.Text + "' " + 
			" ,CountryCode = '" + txtCountryCode.Text + "' " + " ,Budget = '" + txtBudget.Text + "' " +
			" ,Used = '" + txtUsed.Text + "' " + " WHERE CustomerID = '" + myGridView.DataKeys[e.RowIndex].Value + "'";
		    
	        myDSource.UpdateCommand = strSQL;
	        myDSource.UpdateCommandType = SqlDataSourceCommandType.Text;
	        myDSource.Update();
		    
		    myGridView.EditIndex = -1;
		    myGridView.ShowFooter = true;
		    BindData();
		}


</script>
<html>
<head>
    <title>ThaiCreate.Com ASP.NET - SqlDataSource</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView id="myGridView" runat="server" AutoGenerateColumns="False" 
	ShowFooter="True" 
	DataKeyNames="CustomerID"
	OnRowEditing="modEditCommand"
	OnRowCancelingEdit="modCancelCommand"
	OnRowDeleting="modDeleteCommand"
	OnRowUpdating="modUpdateCommand"
	OnRowCommand="myGridView_RowCommand">

	<Columns>

	<asp:TemplateField HeaderText="CustomerID">
		<ItemTemplate>
			<asp:Label id="lblCustomerID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CustomerID") %>'></asp:Label>
		</ItemTemplate>
		<EditItemTemplate>
			<asp:TextBox id="txtEditCustomerID" size="5" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CustomerID") %>'></asp:TextBox>
		</EditItemTemplate>
		<FooterTemplate>
			<asp:TextBox id="txtAddCustomerID" size="5" runat="server"></asp:TextBox>
		</FooterTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="Name">
		<ItemTemplate>
			<asp:Label id="lblName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>'></asp:Label>
		</ItemTemplate>
		<EditItemTemplate>
			<asp:TextBox id="txtEditName" size="10" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>'></asp:TextBox>
		</EditItemTemplate>
		<FooterTemplate>
			<asp:TextBox id="txtAddName" size="10" runat="server"></asp:TextBox>
		</FooterTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="Email">
		<ItemTemplate>
			<asp:Label id="lblEmail" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Email") %>'></asp:Label>
		</ItemTemplate>
		<EditItemTemplate>
			<asp:TextBox id="txtEditEmail" size="20" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Email") %>'></asp:TextBox>
		</EditItemTemplate>
		<FooterTemplate>
			<asp:TextBox id="txtAddEmail" size="20" runat="server"></asp:TextBox>
		</FooterTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="CountryCode">
		<ItemTemplate>
			<asp:Label id="lblCountryCode" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CountryCode") %>'></asp:Label>
		</ItemTemplate>
		<EditItemTemplate>
			<asp:TextBox id="txtEditCountryCode" size="2" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CountryCode") %>'></asp:TextBox>
		</EditItemTemplate>
		<FooterTemplate>
			<asp:TextBox id="txtAddCountryCode" size="2" runat="server"></asp:TextBox>
		</FooterTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="Budget">
		<ItemTemplate>
			<asp:Label id="lblBudget" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Budget") %>'></asp:Label>
		</ItemTemplate>
		<EditItemTemplate>
			<asp:TextBox id="txtEditBudget" size="6" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Budget") %>'></asp:TextBox>
		</EditItemTemplate>
		<FooterTemplate>
			<asp:TextBox id="txtAddBudget" size="6" runat="server"></asp:TextBox>
		</FooterTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="Used">
		<ItemTemplate>
			<asp:Label id="lblUsed" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Used") %>'></asp:Label>
		</ItemTemplate>
		<EditItemTemplate>
			<asp:TextBox id="txtEditUsed" size="6" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Used") %>'></asp:TextBox>
		</EditItemTemplate>
		<FooterTemplate>
			<asp:TextBox id="txtAddUsed" size="6" runat="server"></asp:TextBox>
			<asp:Button id="btnAdd" runat="server" Text="Add" CommandName="Add"></asp:Button>
		</FooterTemplate>
	</asp:TemplateField>

	<asp:CommandField ShowEditButton="True" CancelText="Cancel" DeleteText="Delete" EditText="Edit" UpdateText="Update" HeaderText="Modify"  />
	<asp:CommandField ShowDeleteButton="True" HeaderText="Delete" />
	
	</Columns>
</asp:GridView>
</form>
</body>
</html>

Date : 2009-11-25 13:32:23 By : Maklee
 


 

No. 5



โพสกระทู้ ( 179 )
บทความ ( 0 )



สถานะออฟไลน์


โค้ด ตัวอย่างก็หน้าจะใช้ได้นะ แล้วได้ไปแก้ อะไรบ้างครับ
System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"] ลองตรวจสอบดูก่อนครับ ตรงนี้ ว่ามันมีค่าหรือเปล่า หรือลอง Print ค่าออกมาแสดงดูก่อนนะครับว่ามันมีค่าเป็นอะไร
ผมว่ามันเกี่ยวกับ การกำหนดค่าแน่นอนครับ

หรือว่าต้องการจะทำอะไรบ้างครับ เดี้ยวผมเขียนตัวอย่างให้เลย ^^
Date : 2009-11-25 14:03:42 By : ksillapapan
 


 

No. 6



โพสกระทู้ ( 54 )
บทความ ( 0 )



สถานะออฟไลน์


เรื่องของเรื่องก็มีอยู่ว่าไม่เคยเขียนมาก่อนค่ะ แต่มีพิ้นฐานการเขียน PHP บ้างค่ะ ต้องการ insert ข้อมูลโดยออกแบบให้ textbox แสดงในตารางที่ใช้ web control ของhtml แล้วให้สามารถนำออกมาแก้ไข หรือลบที่ Gridview นะค่ะ ช่วยแนะนำด้วยค่ะคุณ Poo
Date : 2009-12-01 16:49:45 By : Maklee
 


 

No. 7



โพสกระทู้ ( 179 )
บทความ ( 0 )



สถานะออฟไลน์


ลองเริ่มจากการกำหนด WebCofig ก่อนนะครับ มีวิธีง่ายๆอยู่ลองเข้าไปดูนะ
http://itdevclub.blogspot.com/2009/11/webconfig.html
มันเพิ่งหัดเขียน Blog เลยงง ส่วนตัวอย่างเดี้ยวเขียนให้นะครับ ^^
Date : 2009-12-04 11:44:35 By : ksillapapan
 


 

No. 8



โพสกระทู้ ( 179 )
บทความ ( 0 )



สถานะออฟไลน์


ใน เว็บบอร์ดครับ หน้าจะครบเลยนะครับ

https://www.thaicreate.com/asp.net/asp.net-gridview-control-rowcommand-edit-update-cancel-add.html

หรือถ้าจะไม่ใช้แบบนี้ มันก้มีอีกหลาย แบบ
แนะนำครับ ออกแบบ
1) ต้องการให้ จัดการทุกอย่างในตาราง ก็คงใช้แบบตัวอย่างได้เลย แต่ ถ้าไม่ใช้แบบนั้นก็ ต้องมากำหนด ว่าต้องการให้มี Form อะไรบ้าง เช่น Form Edit,Insert,Search,Delete อะไรพวกนี้อ่ะครับ

ออกแบบได้ยังไงก็มาเล่ากันฟัง จะได้ช่วยๆๆ กันแนะนำครับ ^^
Date : 2009-12-04 12:18:52 By : ksillapapan
 


 

No. 9



โพสกระทู้ ( 538 )
บทความ ( 3 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


เอ่อ ช่วย check ตรงนี้ให้หน่อยครับ สอบ MCDBA / MCSD เนี่ยพลาดข้อนี้กันหลายคนเลย

MS SQL 2000 ไม่ได้ใช้แล้วเลยไม่มีรูปให้ดู แต่ให้เปิดหาดูครับ หาจุดเดียวกัน
MS SQL 2005, 2008 เหมือนกันครับ ทำแบบเดียวกันเลย

db properties 1

ตรวจสอบเรื่อง Security ครับ ว่าตั้งค่าไว้แบบไหนอยู่ มีอยู่ 2 แบบตามรูปครับ

db properties 2

คำอธิบาย
แบบ 1 : Windows Authentication mode
ไม่ขออธิบายระเอียดนะครับ ขี้เกียจพิมพ์ (อยากให้ไปหาอ่านเพิ่มเองด้วยอ่ะ ) ถ้าเลือกแบบนี้ ไม่ต้องใช้ username/password ครับ แต่จะตรวจสอบจาก user login ของเครื่องลูกที่เชื่อมต่อเข้ามาว่ามีสิทธิเข้าใช้ database หรือเปล่า วิธีนี้ทั้งระบบต้องเป็น pure Microsoft Architecture ครับ ขอบอกว่า ยุ่งยากมาก = ='

แบบ 2 : SQL Server and Windows Authentication mode
แบบนี้ล่ะครับที่พวกเราๆ ใช้กันอยู่ คือต้องมีการสร้าง username สำหรับ database host และ database แต่ละตัวที่อยู่ใน host นั้นๆอยู่ด้วยอ่ะครับ (ตามปกติแล้ว เวลาสร้าง username มันจะมีให้ set ด้วยว่า user นี้จะใช้กับ database ไหน นั่นล่ะครับ) ถ้าเราต้องการใช้ username/password สำหรับ login เข้า database ดังตัวอย่างที่เอามาแสดงใน คห. ก่อนหน้าต้องเลือก Security properties ของเครื่องที่เป็น database ไว้ที่ข้อนี้ด้วยครับ


Database host := เครื่องที่ลงโปรแกรม MS SQL ไว้ครับ
Database := ใน 1 database host เราสามารถสร้าง database ไว้ได้หลายๆ database ครับ ขึ้นอยู่กับประสิทธิภาพเครื่องของเราว่ารับได้กี่ database ครับ

หวังว่าคงช่วยได้เนาะ ^^"
Date : 2009-12-06 00:30:26 By : salapao_codeman
 


 

No. 10



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


Code
ปัญหาของน้องคือ ยังไม่ได้เพิ่ม AppSettings ที่ใช้ user และ password ที่ connect ms sql ได้ลงใน web.config

Date : 2009-12-06 13:11:04 By : plakrim
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รันงานไม่ได้ค่ะ c# มันฟ้องแบบนี้ ฟ้องแบบนี้ต้องแก้ไขไงค่ะ Login failed for user ''. The user is not associated with a trusted SQL Server connection.
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่