How To Write The Code For Connection In C#.net

Jan 4, 2008

 what is the simple way of writing code for the connection  with sql server  in c# .net

could any one provideme with the code for the same ism not been able to understand the funda  of using class for the connection purpose

if any one knows plz let me know i am waiting

View 3 Replies


ADVERTISEMENT

How Do I Write It In The Code?

May 20, 2005

Hejsan!
I have a page with with diffrent short news. They are in a Database
(MS SQL) and now they saving all after the other, but I should want to
only have 3 news in the DB, and when I write in a new short news it
should be saved over one of them older new witch is in the databaseHow
can I do that? Anyone who nows to write that in the code?mvh Sanne
My code looks like this now:<script runat="server">
    Sub Page_Load(sender As Object, e As EventArgs)       Dim myConnection As SqlConnection       Dim myCommand As SqlDataAdapter       ' Create a connection to the "pubs" SQL database located on the       ' local computer.         
myConnection = New
SqlConnection("server=xxxxx;UID=xxxx;PWD=xxxx;Initial Catalog=xxx;")       ' Connect to the SQL database using a SQL SELECT query to get all       ' the data from the "notistabell" table.       myCommand = New SqlDataAdapter("SELECT * FROM notiser ORDER BY ID Desc", myConnection)       ' Create and fill a DataSet.       Dim ds As DataSet = new DataSet()       myCommand.Fill(ds)       ' Bind MyDataList to the DataSet. MyDataList is the ID for       ' the DataList control in the HTML section of the page.       MyDataList.DataSource = ds       MyDataList.DataBind()    End Sub
</script>

View 1 Replies View Related

HOW TO WRITE THIS CODE?

Apr 4, 2008

OKAY I have one table "Data" with about 7 million records.
Now I want to create the following output table. THe range (1 to 15) can always change in the "data" table. How would I write a script to do this?

Data
StartEndTime
1155:45
20262:26
1521607:52



Output
ValueTime
15:45
25:45
35:45
45:45
55:45
65:45
75:45
85:45
95:45
105:45
115:45
125:45
135:45
145:45
155:45
202:26
212:26
222:26
232:26
242:26
252:26
262:26
1527:52
1537:52
1547:52
1557:52
1567:52
1577:52
1587:52
1597:52
1607:52

View 9 Replies View Related

How Can We Write C# Code In Sql.

Feb 19, 2006

Hello

Anybody knows how to write c# in SQL?

All responses appreciated.

thanks.





View 6 Replies View Related

How To Write Code Without Cursor

Aug 25, 2014

I wrote the foollowing cursor code but it takes too long.how i can write it without cursor?

ALTER PROCEDURE [dbo].[usp_AMPPU_Teamleader]
AS
BEGIN
SET NOCOUNT ON;

[code]....

View 8 Replies View Related

Where Can I Write Vb.net Code To Run Rs.exe Utility

May 16, 2008



Hi,
I want to write a script in Vb.net and use that script in rs.exe utility..but i am not able to understand where should i have to write the script in Vb.net for reporting services.
Why i am writing the script code is???

In Report manger,i am trying to restrict folders and reports for particular persons only like manger can see all the reports,advisor can view only related reports.
this can do by using item level security in report manger by creating roles and we can add the users in to the role.
but that was not happenning..planning for another way to implement the scenario.

I came to know that we can write scripting in vb.net and we can run thru rs.exe utility in SSRS.

1.But where can i write the vb.net script?
2.How to migrate that code to report manager?
3.Can we debug that code?
4.How to use SOAP API in RS?

Pls reply back..this one i have to do with in one day..


View 1 Replies View Related

Trying To Work Out Why My Code Wont Update Or Write To The DB

Jan 7, 2008

hi there, i have been wrestling with this for quite a while, as in my other post http://forums.asp.net/t/1194975.aspx, what someone advised me was to put in try catch blocks ot see whats going on, problem is i have never really done it whit this kinda thing before, and i was wondering if someone could point me in the right direction.
 
For example where would i put the try catch block in here, to show me if its not working public int getLocationID(int ProductID, int StockLoc)
{
// Gets the LocationID (Shelf ID?) for the stock column and product id
// passed
// The SQL will look Something like: string strSQL;
strSQL = "SELECT " + " location" + StockLoc + " " + "FROM " + " tbl_stock_part_multi_location " + "WHERE " + " stock_id = " + ProductID;string sConnectionString = "Data Source=xxxxx;Initial Catalog=xxxx;User ID=xxxx;Password=xxxxx";
SqlConnection objConnGetLocationID = new SqlConnection(sConnectionString);SqlCommand sqlCmdGetLocationID = new SqlCommand(strSQL, objConnGetLocationID);
objConnGetLocationID.Open();int intLocation = Convert.ToInt32(sqlCmdGetLocationID.ExecuteScalar());
return intLocation;
}

View 6 Replies View Related

How To Write Portable Database Access Code?

Jul 20, 2005

I can access Microsoft Access database via ODBC on Windows 2000 usingC++. Now, I would like to use the SAME piece of code to access MS SQLon Windows. Can I achieve this without any modification to my existingcodes?Then, I would like to use the SAME piece of codes to access Oracleon Windows? Is it possible?Thanks in advance!

View 1 Replies View Related

How To Write Backup Code For Sql Server 2000

Aug 29, 2006

hi Experts,

any one tell me that how to write code to take back up of sql server database?

View 5 Replies View Related

HOW TO WRITE A LOGIC IN SQL SERVER USING THIS COBAL CODE

May 25, 2008

sub = 1

DETAILED-VOUCHER

VOUCHER-A OCCURS 13 TIMES.
ACC-NUM PIC X(6).

ADB-V OCCURS 12 TIMES.
CNT-V PIC 9999 COMP-3.
AMT-V PIC S9(9)V99 COMP-3.

It is a initialization of the two dimensional array DETAILED-VOUCHER(Temporary Variable) which consists of the account number for that account number different group of people say as (teachers, state police etc) have different 12 kinds of amounts such as (DEATH-AMT, PAYEE-AMTetc ) for every account number. SUB (Temporary Variable) is used as subscript whose value will be incremented by 1 after initializing current position by zero in order to initialize all 12 positions in array.



LOP-ZERO-2.
MOVE ZEROS TO CNT-V (1 SUB).
MOVE ZEROS TO AMT-V (1 SUB).
ADD 1 TO SUB.
IF SUB NOT GREATER THAN 12
GO TO LOP-ZERO-2.


MOVE 2 TO SUB.

LOP-ZERO-3.
MOVE CNTS (1) TO CNTS (sub).
ADD 1 TO SUB.
IF SUB NOT > 13 GO TO LOP-ZERO-3.



MOVE '401.21' TO ACC-NO-V (1). ---------- This are the hotcode values
MOVE '410.01' TO ACC-NO-V (2).
MOVE '410.02' TO ACC-NO-V (3).
MOVE '410.03' TO ACC-NO-V (4).
MOVE '410.04' TO ACC-NO-V (5).
MOVE '410.06' TO ACC-NO-V (6).
MOVE '410.05' TO ACC-NO-V (7).
MOVE '411.01' TO ACC-NO-V (8).
MOVE '411.02' TO ACC-NO-V (9).
MOVE '331.01' TO ACC-NO-V (10).
MOVE '212.19' TO ACC-NO-V (11).
MOVE '212.22' TO ACC-NO-V (12).


MOVE ZEROS TO XYZ-S (1).
MOVE ZEROS TO MNO-B (1).
MOVE ALL '9' TO A-KEY
MOVE 01 TO D-X.
MOVE 1 TO SYS-Y



Please give suggest me how to write logic in the sql server. I want to how to write two dimensional array loop in the sql server.

View 1 Replies View Related

Ugrent Help: How To Write Code To Execute A Batch File

Apr 15, 1999

hi, I need to run a batch file in specific time of the week. can anyone show me the code to run a batch file with both ways: window nt schedualer and ms sql server task manger.... I do appreciate your help

Ali

View 5 Replies View Related

Can I Write A Dll(or Share The Same Code) That Works On Both Mobile Device And Pc?

May 4, 2007

hi,

Can I write a dll(or share the same code) that works on both Mobile device and pc? Since we are using compact edition, we are hoping we can write some common module with the same code that could works on both mobile device and pc platform. I noticed the reference is the same, System.Data.SqlServerCe.dll 3.0.

Another question is, we already have a module for SQLCE2.0, with .net CF1.0. Now, we will start to use compact edition, should we just update on the 1.0 one, or we have to write a different one based on .net CF2.0? Can I use compact edition in CF1.0 dll?



Thanks.

View 1 Replies View Related

Write Code To Combine Two Tables And Then Return Maximum Value Of One Table

Sep 17, 2012

I am TRYING to write code to combine two tables and then return the maximum value of one table, but SQL Server keeps telling me that the column is not valid.... I have added attached screenshots to show that it IS a valid column, so I cannot figure out what is the retarded issue!!

View 11 Replies View Related

The AcquireConnection Method Call To The Connection Manager &&<Connection Name&&> Failed With Error Code 0xC020200

Feb 14, 2008

Hi All,
I am getting the following error if I am using the package "Transaction Option=Required" while running through Sql Job:
The AcquireConnection method call to the connection manager "<connection name>" failed with error code 0xC0202009.

while I running the SSIS package on BI environment, I am getting the following error:
[Connection manager "<connection name>"] Error: The SSIS Runtime has failed to enlist the OLE DB connection in a distributed transaction with error 0x8004D00A "Unable to enlist in the transaction.".

I know the alternative solution is to make the "Transaction Option=Supported", but in my case I have run the whole flow in a single transaction. I came to know that this has been fixed in the service pack1(ref. to http://support.microsoft.com/kb/914375). FYI.. some time it was running successful.

I have taken all the necessary step to run the SSIS package in a distributed transaction(like the steps for MSDTC) and also created the package flow in a sequence.

I was going through the link - http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=160340&SiteID=1 but all those didn't solve my problem.

If anyone can help me it will be great. or it is a bug in SSIS?

Thanks.
Jena

View 5 Replies View Related

How To Create Apps That Write Code To Retrieve Data With Foreign Keys?

Apr 6, 2007

Hi GuysOff late, I've grown with programming that requires more than a number of tables that has foreign keys with other tables' primary keys. It takes a really cumbersome coding to retrieve the code from another table with the other table having foreign keys. My question is, how do we program VS 2005 such that it does all the retrieval of the data from the database instead of us writing the code all by ourself?Is it really good database technique to bend the normalcy rules and have one to two columns having redundant data?Can anyone tell me how to write code that retrieves the foreign key data when the data from the other table is called?Thanks

View 2 Replies View Related

Integration Services :: How To Write ETL Package Addressing Different Collations Or Code Pages

Jul 13, 2015

Default code page in ETL package is 1252 which will not work if the collation is different e.g in Japanese_CI_AS, it is 932.

My question is how to write a generic ETL package so that it can cater any collation or any code page.

View 5 Replies View Related

SSPI Handshake Failed With Error Code 0x8009030c While Establishing A Connection With Integrated Security; The Connection Has Be

Mar 7, 2006

Hello, I have a sql 2005 server, and I am a developer, with the database on my own machine. It alwayws works for me but after some minutes the other developer cant work in the application

He got this error

Login failed for user ''. The user is not associated with a trusted SQL Server connection. [CLIENT: 192.168.1.140]

and When I see the log event after that error, it comes with another error.

SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; the connection has been closed. [CLIENT: 192.168.1.140]

He has IIS5 and me too.

I created a user on the domain called ASPSYS with password, then in the IIS on anonymous authentication I put that user with that password, and it works, on both machines.



and in the connection string I have.

<add key="sqlconn" value="Data Source=ESTACION15;Initial Catalog=GescomDefinitiva;Integrated Security=SSPI; Trusted_Connection=true"/>

I go to the profiler, and I see that when he browses a page, the database is accesed with user ASPSYS, but when I browse a page, the database is accesed with user SElevalencia.

Thats strange.

The only way that the other developer can work again on the project is to restart the whole machine. He has windows xp profession, I have windows 2000.

If you want me to send logs please tellme



View 20 Replies View Related

The AcquireConnection Method Call To The Connection Manager Excel Connection Manager Failed With Error Code 0xC0202009

Mar 24, 2008

I am using SSIS 2005 on Windows 2003 server. Using Excel Source to dump the data for staging database.
I am getting following error while I execute it through BI studio's execute button.

Please help.

- Sachin

View 2 Replies View Related

The AcquireConnection Method Call To The Connection Manager Excel Connection Manager Failed With Error Code 0xC0202009

Mar 11, 2008

I have deployed my packages into Sql Server and I am using Configuration File. As my Data Source is Excel, I have changed the connection string during deployment with Server Path. But I am getting the following errors. Actually the File Exist in Path. May I know What is cause of the issue? Do I need to give any permission to execute the package.



SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.



component "Excel Source Service Contract Upload" (1) failed validation and returned error code 0xC020801C.

One or more component failed validation.



There were errors during task validation.

DTS_E_OLEDBERROR, Error Code: 0x80004005 Source: "MS JET DB Engine" Description : Path is not valid


View 27 Replies View Related

SQL 2000 Reovery Fails Sometimes. Error Code (Error 3136). How To Make Database Write Mode?

Jan 7, 2008

Hello,

I am applying hourly differential backup to the backup server from production with the following command. This command makes the database on standby server into read only mode.


RESTORE DATABASE ARSYSTEM FROM DISK = 'E:SQL backup from productionsql_full_backup'
WITH MOVE 'arsystem' TO
'd:ardataarsystem.mdf' ,
MOVE 'arsystem_log' TO 'D:ARLOGARsystem' ,
STANDBY = 'E:SQL backup from productionSQL daily diff back up'


Now I want to run a command which will put the database in write mode. I have created a job which would make the datbase Write mode. This job runs successfully sometimes and fails sometimes. I need to ensure that the job always succeeds. When it fails, how do I troubleshoot and what is the possible fix?

Thanks in advance.

The error message is

Cannot apply the backup on device 'E:SQL backup from productionSQL daily diff back up' to database 'ARSYSTEM'. [SQLSTATE 42000] (Error 3136) RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013). The step failed.


The steps for the job are as follows with the failing step highlighted in bold.


copy /y "\172.31.9.12Remedy BackupackupSQL backupsql_full_backup" "E:SQL backup from productionsql_full_backup"

copy /y "\172.31.9.12Remedy BackupackupSQL backupSQL daily diff back up" "E:SQL backup from productionSQL daily diff back up"

xp_cmdshell 'net stop "bmc remedy action request system server"'

exec rp_kill_db_processes 'ARSYSTEM'

RESTORE DATABASE ARSYSTEM

FROM DISK = 'E:SQL backup from productionsql_full_backup'

WITH

MOVE 'arsystem' TO 'd:ardataarsystem.mdf' ,

MOVE 'arsystem_log' TO 'D:ARLOGARsystem' ,

NORECOVERY


Failing step

RESTORE DATABASE ARSYSTEM

FROM DISK = 'E:SQL backup from productionSQL daily diff back up'

WITH

MOVE 'arsystem' TO 'd:ardataarsystem.mdf' ,

MOVE 'arsystem_log' TO 'D:ARLOGARsystem' ,

RECOVERY



xp_cmdshell 'del /f "E:SQL backup from productionsql_full_backup"'

xp_cmdshell 'del /f "E:SQL backup from productionsql daily diff back up"'

xp_cmdshell 'net start "bmc remedy action request system server"'





I have scheduled the following hourly diffential restore job too which never fails.

RESTORE DATABASE ARSYSTEM FROM DISK = 'E:SQL backup from productionsql_full_backup'
WITH MOVE 'arsystem' TO
'd:ardataarsystem.mdf' ,
MOVE 'arsystem_log' TO 'D:ARLOGARsystem' ,
STANDBY = 'E:SQL backup from productionSQL daily diff back up'
EXEC MASTER..XP_CMDSHELL 'del /f "E:SQL backup from productionSQL daily diff back up"'

View 12 Replies View Related

Error: The AcquireConnection Method Call To The Connection Manager Excel Connection Manager Failed With Error Code 0xC0202009.

Dec 27, 2007

Hi,

I am working on SQL Server 2005 (x64) with Windows Server 2003 (x64) operating system. I am having a major issue in SSIS. Here is the detailed explanation of the issue :

I have an EXCEL file in 2003 / 2007 version. It contains some data. I want to import the data using SSIS into SQL Server 2005 (x64) database table. I have taken "EXCEL FILE SOURCE" and "SQL Server DESTINATION". It was failed on importing data. Surprisingly it works fine in SQL Server 2005 (x32). Can you please explain why it is NOT woking on (x64) ?

Here is the error code i am getting:

[Excel Source [1]] Error: The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009.

Appreciate your time and patience !!

Thanks

View 3 Replies View Related

What Wrong With My Connection Code?

Apr 19, 2005

Below is my connection code..
Public Class clsConnect
Public Shared Function getConnection () AS SQLConnection
Dim strConn As String = "Data Source=PPS_SERVER;" & _
"Initial Catalog=eCommunity;User ID=sa;Password=pps"
Dim DBConn As SqlConnection
DBConn = New SqlConnection(strConn)
DBConn.Open()
Return DBConn
End Function
 
However when i run the web this error was appeared. what possibility of this problem?
SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.Source Error:



Line 12: DBConn = New SqlConnection(strConn)
Line 13:
Line 14: DBConn.Open()
Line 15:
Line 16: return DBConn

View 2 Replies View Related

Code For GPRS Connection

May 4, 2008



can anyone please guide me how i can check whether the GPRS connection is active or not on windows mobile based application? whats the code for it? because i need to synchronize my data based on the status of GPRS connection.
thanks and regards
dhruvi

View 1 Replies View Related

Connection String Designer Code

May 2, 2008

I currently have the following code in my designer file
<asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="select Site_name, system_id, ASP_Archive, sitetimes,HPOV_ROC, UPPER(CircuitType) as CircuitType, QwestCircuit_ID, SiteConfig,Site_Nat, PVC_VCI from tblASPCustomerWan order by Asp_Archive asc"
UpdateCommand="UPDATE tblASPCustomerWan SET [Site_name] = @Site_name, [system_id] = @system_id, [ASP_Archive] = @ASP_Archive, [sitetimes] = @sitetimes, [HPOV_ROC] = @HPOV_ROC, [CircuitType] = @CircuitType, [QwestCircuit_ID] = @QwestCircuit_ID, [SiteConfig]= @SiteConfig, [Site_Nat]=@Site_Nat,[PVC_VCI]=@PVC_VCI"
ConnectionString="server=localhost;Trusted_Connection=yes;uid=portal_user;pwd=Cr@zyP@55w0rd;database=CusPortal_Staging" />
I would like the change the connection so it takes it value from System.Configuration.ConfigurationManager.AppSettings("appStrConnection"), how can i do that??

View 1 Replies View Related

How To Copy Connection String Code

Apr 19, 2008



hi,

i was able to succesfully configure my remote server over the internet and tried using express edition to connect to my remote server and everything when successful.

is there a way to copy that connection string used to connect to my remote server so as i wanted to create a project in vb using that connection string..

where can i find the connection string code used for my connection remotely ..

i am using express to connect to my sql server

thanks

View 4 Replies View Related

Referring To Sql Connection String In Web.config From Code Behind

May 15, 2007

Every time I move my project from my computer to the testing server I have to change the connection string references in the aspx side and in my code behind.
For the code behind I declared the SqlConnection string at the top of the code-behind page for both connection strings and comment out the one not in use. Obviously I then comment out the string not in use in the WebConfig as well.
Being superlatively lazy I always look for the easiest and quickest way to do most anything - connection strings included. Having to comment out strings twice brought rise to the question of whether I can refer to the connection string in the web.config file from the code-behind page. I'm sure it can be done, and I did a good amount of hunting around, but I couldn't find any examples of code that would do that.
Currently, as I said above, I have two connection strings declared at the top of my code-behind. Here's an example of one:Private sqlConn As New SqlConnection("Data Source=DATABASESERVER;Initial Catalog=DATABASE;User ID=USER;Password=PASSWORD")
 Then, I just use sqlConn as usual in my binding without having to "dim" it in every sub:sdaPersonnel = New SqlDataAdapter(strSqlPersonnel, sqlConn)
 Then there's the SqlConnections set up by the wizard on the aspx side:<asp:SqlDataSource ID="sqlDataSourcePayrollCompany" Runat="Server" ConnectionString="<%$ ConnectionStrings:DATABASECONNECTIONSTRING %>" ...>
 And for the connection in the web.config:<add name="DATABASECONNECTIONSTRING" connectionString="Data Source=DATABASESERVER;Initial Catalog=DATABASE;User ID=USER;Password=PASSWORD" providerName="System.Data.SqlClient" />
 So, what would be the code in the code-behind page to refer to the connection string in the web.config file?
Thanks!

View 2 Replies View Related

Using Web.config Connection Strings In Code Behind Files

Jul 2, 2007

in asp usually i have code behind files those .aspx.vb file.can i make use of connection strings in there? i am not really familiar with connection strings. actually shouldn't code behind files "simulate" code being in the .aspx file themselves? i seem to not able to share variables between them? 

View 2 Replies View Related

Best Practice Advice For Efficient SQL Connection Code

Feb 26, 2006

Hi,
I have an application which is similar to the following example
Private Sub Start()For a as int16 = 1 to 300lstResults.items.add(GetPriceFromItem(a))NextEnd Sub
Private Function GetPriceFromItem(byval item as int16) as String'Connect to SQL'Execute "SELECT Price FROM Table WHERE Item='" & item.tostring & "'"'Close Database connection'Return PriceEnd Function
I want to know if there is a more efficeint way of doing this, i.e. i'm concerned that the routine creates 300 SqlConnection instances, 300 open/closes and 300 queries
Would a better way be to connect to SQL once, get the entire table then do the 300 "lookups" locally somehow, perhaps put it all into a DataTable, but can you query a datatable in this way, or could you suggest another control.
Best Regards
Ben
 
 

View 7 Replies View Related

Error Code 0xC0202009 + Connection Password

Dec 15, 2005

Hi,

I have developed a .dtsx package than runs normally from my computer. When I import it on the server and assign it to a job it always fails.

I tried also to run it directly from the server (remote desktop) and also faild. I exported the dtsx file on server and refresh the db connections and after that workd fine from the server.

Another work-around was to use windows authentication. Then runs normally from the server.

It seems that connection password is lost when importing the report on server. (The import is done in MSDB not in the filesystem)

But I can not design all the jobs on the server (work-around A) or use windows authentication (work-around B)

What is the problem and what can I do?

I have also played around with "save sensitive information" but with no results.

Thanks

View 10 Replies View Related

Connection.close Returns A 91 Error Code...

Nov 22, 2006

I have the next code in my proyect:

If CurrentProject.IsConnected Then
MsgBox "Base ya Conectada.Procedemos a cerrarla primero", vbOKOnly
If SQLConexion.State = adStateOpen Then SQLConexion.Close
SQLConexion.Close
End If
SQLConexion.Open SQLSentencia
AbreConexionSQLSERVER = 0

If I detect that the connection is opened while I am initializazing varriables, I want to close always the connection and then begins my aplicattion always opening the connection, but it always returns a error 91..

suggestions?

View 1 Replies View Related

Connection String And Permission Errors In The CLR Code

Feb 28, 2008

I have written a CLR function in C# to access a sql server different from the current server where I have deplyed the assembly.


DataSet ds = new DataSet();





SqlCommand sqlCmd = new SqlCommand();

sqlCmd.CommandType = CommandType.StoredProcedure;

string connString = "Data Source=SQLSERVER;Initial Catalog=DATABASE;User ID=userid;Password=password;";

SqlConnection sqlConn = new SqlConnection(connString);

sqlCmd.Connection = sqlConn;

sqlConn.Open();

try

{

SqlDataAdapter sda = new SqlDataAdapter();

sqlCmd.CommandText = "StoredProcedureName";

sqlCmd.Parameters.Add("@Param1", SqlDbType.VarChar);

sqlCmd.Parameters["@Param1"].Value = sParam1;

sda.SelectCommand = sqlCmd;

sda.Fill(ds);

}

finally

{

sqlConn.Close();

}

return ds;

I was getting the following error

"Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

so I tried doing the following


SqlClientPermission pSql = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);

pSql.Assert();



and then I get this error


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


Any idea how to remedy this ?

Thanks in advance
- Kan

View 4 Replies View Related

Code For Connection String Using Sql Server 2000 As Backend With Asp.net 1.1 Along With Vb.net

Apr 15, 2008

Hi all,
Please help me for the code of connectivity
it was working fine,but,when i hav written code for validation for id n password,its showing error as
Violation of PRIMARY KEY constraint 'PK_Login'. Cannot insert duplicate key in object 'login_detail'. The statement has been terminated.
 Here is my code given below.
 Please help me
Imports System
Imports System.IO
Imports System.Xml
Imports System.Text
Imports System.Security.Cryptography
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data
Imports System.Data.SqlClientPublic Class WebForm1
Inherits System.Web.UI.Page#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End SubProtected WithEvents txtUser As System.Web.UI.WebControls.TextBox
Protected WithEvents txtPwd As System.Web.UI.WebControls.TextBoxProtected WithEvents btnSubmit As System.Web.UI.WebControls.Button
Protected WithEvents lblError As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End RegionPrivate Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
 Dim objConn As SqlClient.SqlConnection
Dim ds As New DataSetDim m_strConnection As String = "server=172.16.152.17;Database=Trial;UID=abhi_Asset4;PWD=L!nux001;Connect Timeout=100"objConn = New SqlClient.SqlConnection
objConn.ConnectionString = m_strConnection
objConn.Open()
Dim strSQL As String
strSQL = "insert into login_detail(UserID,Password) values('" + txtUser.Text + "','" + txtPwd.Text + "')"Dim objCommand As SqlClient.SqlCommandobjCommand = New SqlClient.SqlCommand(strSQL, objConn)
objCommand.CommandText = strSQL
objCommand.ExecuteNonQuery()
objConn.Close()
 
 
 
 
End SubPrivate Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If (txtUser.Text.Trim() = "") Then
lblError.Text = "UserID should not be blank"
ElseIf (Convert.ToInt32(txtUser.Text.Length) < 5) Then
lblError.Text = "UserID length must be more than 5"
ElseIf (Convert.ToInt32(txtUser.Text.Length) > 20) Then
lblError.Text = "UserID length must not be greater than 20"
ElseIf (txtPwd.Text.Trim() = "") Then
lblError.Text = "Password should not be blank"
ElseIf (Convert.ToInt32(txtPwd.Text.Length) < 5) Then
lblError.Text = "Password length must be more than 5"
ElseIf (Convert.ToInt32(txtPwd.Text.Length) > 20) Then
lblError.Text = "Password length must not be greater than 20"
Else
Server.Transfer("Success.aspx")
End IfEnd Sub
End Class
 
 

View 1 Replies View Related

Ssis Oledb Connection Error Code: 0x80040E21.

Jan 25, 2007

howdy,
i have a sqlserver2005 ssis package which connects to a mysql webserver to upload data. i am connecting via mysql oledb connection and am able to test connect ok through the oledb connection manager. However in my ole db destination editor i get an 0x80040E21 error when trying to preview a table . The full error is :

Error at Data Flow Task [Destination - Query [70]]: An OLE DB error has occurred. Error code: 0x80040E21.

Error at Data Flow Task [Destination - Query [70]]: Opening a rowset for "INFORMATION_SCHEMA.address_book" failed. Check that the object exists in the database.
------------------------------
ADDITIONAL INFORMATION:

Exception from HRESULT: 0xC02020E8 (Microsoft.SqlServer.DTSPipelineWrap)

I can see all the tables in the drop down box in connection manager. This has been driving me nuts for the last 3 days! I have tried changing some of the security connection settings to no avail, (although i am not sure on what these do).I have also tried setting up as an odbc connection using script components but had memory errors after copying several hundred records and the package just hangs. I can go into this in more detail however i dont think they are related issues and i would prefer oledb as i dont have to script my data transfer.

any help much much appreciated.

thanks

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved