启动一个SQL项目并需要一些帮助 [英] Starting an SQL Project and need some help

查看:100
本文介绍了启动一个SQL项目并需要一些帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个远程连接到sql服务器的项目.我需要一些细节方面的帮助.诸如
之类的问题
我是否允许远程连接到sql服务器或通过服务器应用程序通过管道传输数据?

如何设置用于用户注册和身份验证的存储过程.

客户端将通过TCPIP与服务器进行通信,我不确定如何处理通信(即,如何拆分要传输的数据,以及是否应该使用某种自定义协议包装)

cyberm0t0 ...

I''m writing a project that remotely connects to an sql server. I need some help with some details. Questions like,

Do i allow remote connections to the sql server or pipe the data through the server app?

How should I setup the stored procedures for user signup and authentication.

The client will communicate with the server via TCPIP and I''m not sure how I should handle the communications (ie. how do i split the data being transferred and should I wrap that with some kind of custom proctocol)

cyberm0t0...

推荐答案

亲爱的cyberm0t0,

我想告诉您,当您在项目中使用数据库时,需要在代码中编写ConnectionString来建立连接.不需要其他设置.

编写ConnectionString的最佳位置是Web.config(在Web项目中)和App.config(在窗口项目中).

除以下内容外,您不需要任何信息/设置:

Dear cyberm0t0,

I would like to tell that while you are using database in your project you need to write ConnectionString in your code to establish connection. No other settings are required.

Best place to write ConnectionString is Web.config (in Web Project) and App.config (in window project).

You do not need to any information/setting except from following:

<add name="cn" connectionString="server=Server-IP;database=DatabaseName;uid=UserID;pwd=Password" providerName="System.Data.SqlClient"/>



用户注册和身份验证的存储过程:
您需要从用户那里接收两个参数,一个是UserName,另一个是Password.如果用户存在,您将检查密码.否则,显示错误的用户消息.让我简化您的工作:



Stored procedure for user signup and authentication:
You need recieve two parameter from user One is UserName and Another is Password. You will check password if User exists. Otherwise Show wrong user message. let me make your work easy:

Create PROCEDURE SPName
(
@unam varchar(50),
@upwd varchar(50),
@regcod int out
)
as
declare @ap varbinary(50)
select @ap= cast(upwd as varbinary(50)) from tbusr where cast(unam as varbinary(50))=cast(@unam as varbinary(50))
if @ap is null
begin
set @regcod=0;
end
else if @ap=cast(@upwd as varbinary(50))
begin
select @regcod= uregcod from tbusr where unam=@unam
end
else
begin
set @regcod=-1;
end



@regcod是一个输出参数,返回其个人资料ID供进一步使用.
希望对您有所帮助.

问候!
阿曼



@regcod is an output parameter which return his profile id for further use.
I hope it will help use.

Regards!
Aman


这篇关于启动一个SQL项目并需要一些帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆