金仓数据库切换数据库的语句是什么呀?

金仓数据库切换数据库的语句是什么呀?,第1张

1、查看当前用户连接数:select connections()

2、修改用户new_user的最大并发连接数为50:alter user new_user with connection limit 50

3、修改用户new_user的最大连接时间为2小时:alter user new_user with connection duration 120

4、修改用户new_user的最大空闲时间为2小时:alter user new_user with connect idle time 120

重点是下面配置文件的修改,修改KingBaseES\data下的kingbase.conf的最大并发连接数:

max_connections = 50

最后,重启金仓数据库实例,例如:使用ikrms.exe工具:

start kingbase kingbasees1(实例名)

stop kingbase kingbasees1(实例名)

从楼主给的语句看:

CREATE TABLE WORKER(

WNO CHAR(8),

WNAME CHAR(6),

AGE CHAR(3),

POSITION CHAR(10),

WAGE CHAR(4),

DNO CHAR(6))

CREATE TABLE D(

DNO CHAR(6),

DNAME CHAR(10),

MNAME CHAR(6),

ADRESS CHAR(10),

TEL CHAR(12))

CREATE ROLE 王明

GRANT SELECT

ON TABLE WORKER,D

TO 王明

这前面的语句都是比较标准的SQL语句,应该执行是没有问题的;

我认为还是这句话的问题:

GRANT SELECT,D

ON TABLE WORKER

WHEN USER()=WNAME

TO ALL

确认一些user()和WNAME代表的是什么?

就可以找到问题原因。

金仓数据库 ?

-----------------------给你一段C# *** 作sqlserver的示例代码

1.数据库建表,

create table mytable(

pkid nvarchar(40) not null,

a nvarchar(40) null

)

insert into mytable(pkid,a) values(newid(),'测试')

2.新建对应此表的实体类

[Serializable]

public class mytable

{

private String _pkid = ""

public String pkid

{

get { return _pkid}

set { _pkid = value}

}

private String _a = ""

public String a

{

get { return _a}

set { _a = value}

}

}

3.新建 *** 作类:

public class mytableDAO

{

private String _ConnectionString

public mytableDAO(String ConnectionString)

{

this._ConnectionString = ConnectionString

}

public int New(Entities.MsgRecord obj)

{

String sql = "insert into mytable(pkid,a) values(@pkid,@a)"

SqlConnection cn = new SqlConnection(this._ConnectionString)

SqlCommand cmd = new SqlCommand(sql, cn)

cmd.Parameters.AddWithValue("@a", obj.a)

cmd.Parameters.AddWithValue("@pkid",

String.Empty.Equals(obj.pkid) ? System.Guid.NewGuid().ToString() : obj.pkid)

try

{

if (cn.State != ConnectionState.Open)

cn.Open()

return cmd.ExecuteNonQuery()

}

catch

{

return -1

}

finally

{

if (cn.State != ConnectionState.Closed)

cn.Close()

}

}

public int Update(Entities.mytable obj)

{

String sql = "Update mytable Set a=@a Where pkid=@ObjectID"

SqlConnection cn = new SqlConnection(this._ConnectionString)

SqlCommand cmd = new SqlCommand(sql, cn)

cmd.Parameters.AddWithValue("@a", obj.a)

cmd.Parameters.AddWithValue("@pkid", obj.pkid)

try

{

if (cn.State != ConnectionState.Open)

cn.Open()

return cmd.ExecuteNonQuery()

}

catch

{

return -1

}

finally

{

if (cn.State != ConnectionState.Closed)

cn.Close()

}

}

public int Del(Entities.mytable obj)

{

String sql = "delete from mytable Where pkid=@ObjectID"

SqlConnection cn = new SqlConnection(this._ConnectionString)

SqlCommand cmd = new SqlCommand(sql, cn)

cmd.Parameters.AddWithValue("@ObjectID", obj.pkid)

try

{

if (cn.State != ConnectionState.Open)

cn.Open()

return cmd.ExecuteNonQuery()

}

catch

{

return -1

}

finally

{

if (cn.State != ConnectionState.Closed)

cn.Close()

}

}

public int Del(String where)

{

String sql = String.Format("delete from mytable Where {0}", where.ToLower().Replace("update", "").Replace("delete", ""))

SqlConnection cn = new SqlConnection(this._ConnectionString)

SqlCommand cmd = new SqlCommand(sql, cn)

try

{

if (cn.State != ConnectionState.Open)

cn.Open()

return cmd.ExecuteNonQuery()

}

catch

{

return -1

}

finally

{

if (cn.State != ConnectionState.Closed)

cn.Close()

}

}

public DataTable Query(String where)

{

String sql = String.Format("select * from mytable Where {0}", where.ToLower().Replace("update", "").Replace("delete", "").Replace("insert", "").Replace("", "").Replace("--", "").Replace("exec", ""))

try

{

SqlDataAdapter da = new SqlDataAdapter(sql, new SqlConnection(this._ConnectionString))

DataTable dt = new DataTable()

da.Fill(dt)

return dt

}

catch

{

return null

}

}

}

4.在ui中调用:

4.1 新增:

private void NewData()

{

String conn=System.Configuration.ConfigurationManager.ConnectionStrings["dbCon"].ConnectionString

mytableDao dao=new mytableDao(conn)

mytable obj=new mytable()

obj.a=this.txtbox_a.Text

obj.b=this.txtbox_b.Text

obj.c=this.txtbox_c.Text

dao.New(obj)

}

4.2 取数据绑定GridView

private void LoadData_InitGridView()

{

String conn=System.Configuration.ConfigurationManager.ConnectionStrings["dbCon"].ConnectionString

mytableDao dao=new mytableDao(conn)

Table dt=dao.Query(String.Format(" a ='{0}'",this.txtbox_a.Text))

//gridview

this.GridView1.DataSource=dt

this.GridView1.DataBind()

//textbox control

this.textbox_a.Text=dt.Rows[0][0].ToString()

}

4.3删除

private void Del()

{

String conn=System.Configuration.ConfigurationManager.ConnectionStrings["dbCon"].ConnectionString

mytableDao dao=new mytableDao(conn)

//根据条件删除指定记录

dao.Del(where)

}

4.4更新

private void Update()

{

String conn=System.Configuration.ConfigurationManager.ConnectionStrings["dbCon"].ConnectionString

mytableDao dao=new mytableDao(conn)

dao.Update(obj)//obj 为mytable的一个实例:需要更新的

}

5.配置文件中连接信息

<connectionStrings>

<add name="dbCon" connectionString="Data Source=192.168.1.100Initial Catalog=NorthwindUser ID=saPassWord=sa" providerName="System.Data.SqlClient"/>

</connectionStrings>

6.读取连接信息

System.Configuration.ConfigurationManager.ConnectionStrings["dbCon"].ConnectionString


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6770691.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-28
下一篇 2023-03-28

发表评论

登录后才能评论

评论列表(0条)

保存