HOME > .NET Framework > Forum > ช่วยด้วยครับบบบ โค้ดสัั้นๆแต่ Error:ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'addApp' that has parameters: id, appname, ApplicationID, ApplicationName.
ช่วยด้วยครับบบบ โค้ดสัั้นๆแต่ Error:ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'addApp' that has parameters: id, appname, ApplicationID, ApplicationName.
Tag : .NET, Web (ASP.NET), C#, VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)
Date :
2011-03-22 10:12:08
By :
CHizanu
View :
1084
Reply :
1
No. 1
Guest
อันนี้โค้ดเชื่อม DB ครับ ติดมาสองวันแล้ว ขอบคุณล่วงหน้าครับ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace ProjectPTT.LogicLayer1
{
public class DatabaseUnitTest1
{
public DataTable searchEmployee(string Fname, string Lname, string Company)
{
SqlConnection conn;
SqlCommand cmd;
string cmdString = "SELECT * FROM Employee "+
"WHERE Employee.EmployFname Like @Fname AND Employee.EmployLname Like @Lname AND Employee.Company Like @Company";
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
cmd = new SqlCommand(cmdString, conn);
cmd.Parameters.AddWithValue("@Fname","%"+Fname+"%");
cmd.Parameters.AddWithValue("@Lname","%" + Lname + "%");
cmd.Parameters.AddWithValue("@Company", "%" + Company + "%");
conn.Open();
SqlDataReader myReader;
myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataTable returnData = new DataTable();
returnData.Load(myReader);