Dim connStr As String
connStr = "Server=(local);DataBase=user_Info;uid=sa;pwd="
Dim cn As SqlConnection = New SqlConnection(connStr)
cn.Open()
Dim strsql As String
strsql = "select ygid as 编号,ygname as 姓名,ygdept as 部门,ygsex as 性别,ygbirthday as 生日,ygplace as 籍贯, yglevel as 学历,ygspecial as 专业,ygdate1 as 参加工作时间,ygdate2 as 进入公司时间,ygdate3 as 职称时间, ygdate4 as 进入公司时间, ygbusi as 职称,ygdate5 as 起薪时间,ygdate6 as 调入时间,ygno as 档号, ygstatus as 原身份,ygduty as 原职务,ygoffice as 原工作单位, ygremark1 as 备注 from manrecord"
Dim ds As New DataSet()
Dim da As SqlDataAdapter = New SqlDataAdapter(strsql, cn)
Dim table As DataTable
If (DataGrid1.CurrentRowIndex >= 0) Then
table = ds.Tables("manrecord")
table.DefaultView.Delete(DataGrid1.CurrentRowIndex)
If (ds.HasChanges()) Then
da.Update(ds, "manrecord")
End If
ds.Tables("manrecord").AcceptChanges()
Else
MsgBox("请选择一行数据")
End If
cn.Close()
End Sub
我这样写还是不对,不知道有什么问题
if exists (select * from dbo.sysobjects where
id = object_id(N'[dbo].[People]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[People]
GO
CREATE TABLE [dbo].[People] (
[pkID] [int] IDENTITY (1, 1) NOT NULL ,
[FirstName] [char] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[LastName] [char] (100) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
if (!IsPostBack)
{
sql = "Select * FROM People";
People.DataSource = CreateDataSource();
People.DataBind();
}
}
public void Page_Grid(Object sender, DataGridPageChangedEventArgs e)
{
sql = "Select * FROM People";
// Set CurrentPageIndex to the page the user clicked.
People.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.
People.DataSource = CreateDataSource();
People.DataBind();
}
public void People_Edit(Object sender, DataGridCommandEventArgs e)
{
sql = "Select * FROM People";