當前位置:首頁 » 編程語言 » sql調用dll

sql調用dll

發布時間: 2022-04-22 22:27:37

sql SERVER 2000 調用第三方DLL 傳參問題

SQL資料庫中的INT數據類型和你的DLL里的INT數據類型不一致
例如:
VB里的Integer類型存儲為 16位(2 個位元組)的數值形式,其范圍為 -32,768 到 32,767 之間。
而SQL里的Int類型數據范圍是:-2^31~2^31-1的整數

兩者之間的區別很大

建議你將DLL的參數全部轉為string,這樣會更好處理一些。

❷ sql server 2008 如何調用dll

用sp_addextendedproc(具體看相關幫助)
如:

usemaster
go
ifexists(select*fromsysobjectswherename='xp_mm'andtype='X')
begin
execsp_dropextendedproc'xp_mm'
DBCCxp_mm(FREE)
end
go
sp_addextendedproc'xp_mm','xp_mm.dll'
go
grantexeconxp_mmtopublic

使用時:

executemaster.dbo.xp_mm參數。。。

❸ 如何將SQL的資料庫連接封裝到DLL中

使用C#生成dll文件並調用
一、創建dll文件:

例如生成一個md5編碼判斷狀態的文件,即,輸入一個字元串(string A)和一個32位md5編碼(string B),判斷此字元串A對應的32位md5編碼是否與B相等,如果相等返回true,否則返回false。

打開VS 2005,「文件」--》「新建」--「項目」,選擇「Windows 控制項庫」,命名後點擊「確定」,在「UserControl1.cs」中輸入以下代碼:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

using System.Text;
using System.Security.Cryptography;

namespace md5
{
public partial class Program : UserControl
{
#region MD5 32位加密:GetMd5Str32
/// <summary>
/// 32位MD5加密
/// </summary>
/// <param name="strSource">待加密字串</param>
/// <returns>加密後的字串</returns>
public static string GetMd5Str32(string strSource)
{
byte[] bytes = Encoding.ASCII.GetBytes(strSource);
byte[] hashValue = ((System.Security.Cryptography.HashAlgorithm)System.Security.Cryptography.CryptoConfig.CreateFromName("MD5")).ComputeHash(bytes);
StringBuilder sb = new StringBuilder();

for (int i = 0; i < 16; i++)
{
sb.Append(hashValue[i].ToString("x2"));
}

return sb.ToString().ToUpper();
}
#endregion

#region 核對md5編碼是否一致:CheckMd5String()

/// <summary>
/// 核對md5編碼是否一致
/// </summary>
/// <param name="ConvertString"></param>
/// <returns>如果一致返回true,否則返回false</returns>
///
public static bool CheckMd5String(string str1, string str2)
{
string md5String = str1; //需要驗證的字元串
string md5DbString = str2; //需要核對的32位md5編碼

int result = string.Compare(md5.Program.GetMd5Str32(str1), md5DbString, true);
if (result == 0)
{
return true;
}
else
{
return false;
}
}
#endregion
}
}

修改「UserControl1.Designer.cs」中的命名空間為「md5」,方法為「Program」,即可生成dll文件。

在...\bin\Debug文件假下,可以找到相應的dll文件。

二、部署dll流程:

首先把dll文件放到應用程序...\bin\Debug\下;
然後在解決方案中添加引用:右鍵滑鼠-->添加引用-->瀏覽-->選擇dll放置路徑後點擊「確定」。
注意:要在應用文件頭處使用using md5;命令。

測試應用程序代碼,如下:Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using md5;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string str1 = textBox1.Text.ToString();
string md5String = textBox2.Text.ToString();

textBox3.Text = md5.Program.GetMd5Str32(str1);
textBox4.Text = md5.Program.CheckMd5String(str1, md5String).ToString();

}

private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

❹ SQL Server2008可以調用c寫的DLL的方法嗎,如果可以,怎麼調用

給你舉一個列子
create assembly Regex from 'E:TestLibsMSSQLExtMethod.RegexMSSQLExtMethod.RegexbinDebugMSSQLExtMethod.Regex.dll' with permission_set = SAFE
exec sp_configure 'clr enabled',1
RECONFIGURE
create function [dbo].Regex.Math,@Regex nvarchar(max))
returns nvarchar(max) with execute as caller
as
external NAME [Regex].[MSSQLExtMethod.RegexExtends].[Math]
go
create function [dbo].Regex.Replace,@Regex nvarchar(max),@Replace nvarchar(max))
returns nvarchar(max) with execute as caller
as
external NAME [Regex].[MSSQLExtMethod.RegexExtends].[Replace]
go
create function [dbo].Regex.IsMath,@Regex nvarchar(max))
returns bit with execute as caller
as
external NAME [Regex].[MSSQLExtMethod.RegexExtends].[IsMath]
go

❺ 在C#中怎麼將所有的sql語句打包成.dll文件或者其他 在C#程序中又怎麼調用呢

我不明白 你是想生成DLL 還是調用?
如果是調用的話! 你只要把你生成好的DLL放到bin目錄下! 然後在你的項目里 using 你的DLL名稱 然後在項目里 實例化一下你的類名就可以了

❻ Mysql觸發器或存儲過程中能否調用dll

使用非SQL格式dll,也就是平時所寫的,如果打死也不明白就用他就可以。
dll需要事先先注冊,
注冊是:regsvr32 名字.dll
卸載是:regsvr32 /u 名字.dll

[vb] view plain
CREATE TRIGGER [名稱] ON [表名]
AFTER INSERT, UPDATE, DELETE
AS
DECLARE @hr int
DECLARE @obj int
DECLARE @out varchar(200)
exec @hr = sp_oacreate '[名稱空間|工程名].[類名]', @obj out
IF @hr = 0
BEGIN
exec @hr = sp_oamethod @obj,'[函數名]',@out output,'[參數1]','[參數2]',...'[參數N]'
if @hr = 0
BEGIN
print @out
END
END

使用SQL格式的DLL
以下這代碼要放到master資料庫執行

[c-sharp] view plain
CREATE PORC [名字] AS
BEGIN
DECLARE @out varchar(200)
EXEC exec sp_addextendedproc '[函數名]', '[名稱空間|工程名
.dll' --添加dll進來
EXEC @out = [函數名] [參數1] [參數2] ... [參數N] --注意:函數名前不能用@函數名和參數之間,參數和參數之間,不能用,,我用過,報錯了...
EXEC exec sp_sp_dropextendedproc'[函數名]' --這里就是卸載了

直接執行外部程序,例如exe,黑客愛好這代碼
上面的代碼黑客也愛好,為什麼?我才不會告訴你他喜歡用sp_addextendproc來載入xp_cmdshell

[c-sharp] view plain
--以下代碼不是順序執行,只是說明
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE; -- 開啟xp_cmdshell,幾乎不需要執行,多數人不會主要到
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE; -- 這自然是關閉嘍,要做啥非法事的話,就不要執行這句。
EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int --這句是如果不能執行xp_cmdshell時候,例如報127錯誤時修復使用
sp_addextendedproc 'xp_cmdshell','xpsql70.dll' -- 同上
--以下是使用xp_comshell
--有返回值
DECLARE @out int
EXEC @out = xp_cmdshell '[文件名]' '[參數1]' '[參數2]' ... '[參數N]'
無返回值
EXEC xp_comshenll'[文件名]' '[參數1]' '[參數2]' ... '[參數N]',no_output

❼ 關於SQL 擴展存儲過程DLL問題

其他電腦不能運行是因為沒安裝VCR6.0.
1、安裝VCRuntime 6.0。
2、發布dll的時候使用靜態連接庫的方式。發布出來的dll應該是M為單位的。詳細的解決方案網路搜索:VS編譯C++獨立運行程序。

❽ 怎麼用C#編寫個dll,用來讀取SQL資料庫中一張表的數據,然後返回XML格式字元串

這是由兩部操作組成的,一個是你要從資料庫中將這個欄位讀出來,再一個就是將你讀出來的數據賦值textBox.Text中就行,你可以參考一下(別復制粘貼,因為需要按照你的程序修改一下):
//這個方法是用來顯示一個單一的返回值而編寫的,你只需要向其中傳輸你的
//SQL語句就行,這里的返回值的信息就是string 類型的。
public string mysqlfun(string sql)
{
string info = "";
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "Data Source=.;Initial Catalog=你的資料庫的名字;Integrated Security=True";//這是一個連接字元串,考慮
//widows安全模式下登錄
conn.Open();
DataSet objDataSet = new DataSet();
SqlDataAdapter obj = new SqlDataAdapter();
obj.SelectCommand = new SqlCommand(sql, conn);
obj.Fill(objDataSet, "info");
SqlCommand objSqlCommand = new SqlCommand(sql, conn);
SqlDataReader objSqlReader = objSqlCommand.ExecuteReader();
while (objSqlReader.Read())
{
info = objSqlReader.GetValue(0).ToString ();
}
return info;
}
我相信你應該會寫SQL語句吧!
然後就像我剛才說的:
textBox1.Text=info;
這樣就行了。希望能幫到你!!
最後,還有一點提示,看到你的資料庫是master,如果是你自己練習的,最好自己創建一個資料庫,因為master資料庫是一個系統資料庫,使用它感覺不是很好。

❾ 如何調用sqlite3.dll

調用dll分顯示載入和隱式載入。區別在於前者可以指定需要調用的導出函數,後者是全部載入。
sqlite3.dll用隱式載入。
在你的工程中添加sqlite3.h文件。在你需要使用的地方

1
2
3
4
5
6
7
8
9
10
11
12
13
14

#include "sqlite3.h"
#pragma comment( lib, "sqlite3" )

sqlite3* m_pDB = NULL; //資料庫指針
char* szSQL = NULL; //語句
sqlite3_stmt* pStmt = NULL; //指向語句的指針

szSQL = ""; //組裝語句
nRet = sqlite3_exec( m_pDB, szSQL, NULL, NULL, NULL ); //執行

szSQL = ""; //組裝語句
nRet = sqlite3_prepare( m_pDB, szSQL, -1, &pStmt, NULL );
sqlite3_bind_text( pStmt, 1, INTER_ADMIN, -1, SQLITE_STATIC ); //綁定變數
nRet = sqlite3_step( pStmt ); //執行

熱點內容
百度雲下載文件夾 發布:2025-05-18 03:17:33 瀏覽:674
php雲開發 發布:2025-05-18 03:12:41 瀏覽:447
sql語句顯示表 發布:2025-05-18 03:12:30 瀏覽:690
資料庫系統的例子 發布:2025-05-18 03:02:42 瀏覽:191
數字化儲存與編譯是什麼 發布:2025-05-18 02:56:55 瀏覽:217
個人網站模板源碼 發布:2025-05-18 02:51:17 瀏覽:490
主伺服器ip地址 發布:2025-05-18 02:46:29 瀏覽:856
電腦配置太低玩不了絕地求生怎麼辦 發布:2025-05-18 02:38:39 瀏覽:797
存儲過程怎麼出錯了 發布:2025-05-18 02:37:16 瀏覽:368
32寸演算法 發布:2025-05-18 02:22:14 瀏覽:744