Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:53:42+00:00 2026-05-27T04:53:42+00:00

I want to send SMS using GSM modem’s AT-Commands from SQL Server 2008, so

  • 0

I want to send SMS using GSM modem’s AT-Commands from SQL Server 2008, so I wrote a Visual C# SQL CLR Database Project and a stored procedure.

But when I execute that stored procedure I received this error:

Request for the permission of type
‘System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’
failed.

The source codes of stored procedure and the class for sending sms are these:

[Microsoft.SqlServer.Server.SqlProcedure]
public static void SendSMS2(string phone, string message)
{
    SMSManagement.SM2S ss = new SMSManagement.SM2S();
    ss.SendMessage(phone, message);
}

public void SendMessage(string PhoneNumber, string Message)
{
    try
    {
        SerialPort port = new SerialPort();

        port.PortName = "COM5";                
        port.BaudRate = 115200;                  
        port.DataBits = 8;                
        port.StopBits = StopBits.One;     
        port.Parity = Parity.None;        
        port.ReadTimeout = 300;           
        port.WriteTimeout = 300;          

        // Error occurred in here.
        port.Open();
        port.DtrEnable = true;
        port.RtsEnable = true;

        SMS sms = new SMS();
        sms.Direction = SMSDirection.Submited;
        sms.PhoneNumber = PhoneNumber;
        sms.ValidityPeriod = new TimeSpan(4, 0, 0, 0);
        sms.Message = Message;

        Message = sms.Compose(SMS.SMSEncoding.UCS2);

        ExecCommand(port, "AT", 300, "No phone connected");
        ExecCommand(port, "AT+CMGF=0", 300, "Failed to set pdu format.");
        ExecCommand(port, "AT+CMGS=1", 300, "Failed to set message length.");
        string command = Message + char.ConvertFromUtf32(26);
        ExecCommand(port, command, 6000, "Failed to send message"); 

        port.Close();
    }
    catch (Exception ex)
    {
        SqlContext.Pipe.Send(ex.Message);
    }
}

The version of Visual Studio and SQL Server is 2010 SP1 and 2008 R2.
The CLR project framework is 2.0 .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:53:43+00:00Added an answer on May 27, 2026 at 4:53 am

    You didn’t mention how you installed your assembly into SQL Server. If you just deployed straight from Visual Studio – what permission level did you specify??

    enter image description here

    The default value is Safe, which is okay as long as you only work within SQL Server – regex matching or things like that.

    If you want to “reach out” from SQL Server and communicate with the world, you must set the Permission Level to Unsafe before you deploy your assembly into SQL Server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send / receive sms using AT commands from my computer to
I just want to send SMS from my web application in PHP. Can anyone
I have contact list and I want to send an sms using MFMessageComposeViewController and
I'm using the GsmCommMain class to send an sms I want to include a
I want to send SMS from iPhone to another phone with some text and
hai friends In my application i want to send sms using nokia 3310c mobile
I want to do a sample application to send/receive SMS using mobile 5. Can
I want to send a SMS from my application. For that,i use MFMessageComposeViewController and
Possible Duplicate: sms from our site I want to send SMS from my asp.net
Possible Duplicate: How to programmatically send SMS on the iPhone? I want to implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.