|
hi, I have to do a project using daab transaction using Microsoft visual studio(vb) using the enterprise libray too.
is there any website or book anyone can recommend whereby they give step by step or detailed way on how bout doing it???
I am having troubles wif my code, the bolded part has an error and i have no idea y...:
Imports Microsoft.VisualBasic
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Data
Imports System.Transactions
Public Function ConfirmTransactions(ByVal tempCID As String)
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim connection As IDbConnection
Using (connection = [B]db.GetConnection[/B]())
connection.Open()
IDbTransaction(Transaction = connection.BeginTransaction())
Try
db.ExecuteNonQuery(Transaction, "CreditAccount", srcAccount, amount)
db.ExecuteNonQuery(Transaction, "DebitAccount", dstAccount, amount)
Transaction.Commit()
Catch e As Exception
Transaction.Rollback()
End Try
connection.Close()
End Using
End Function
can anyone help me???
or does anyone have a complete set of code for daab transaction??
syl
-- modified at 20:24 Tuesday 28th March, 2006
|
|
|
|
|
Hello Friedns,
I am tring to restore backup file which is on Machine1. And SQL server might be on anyother machine in local network.
I am using this Code:
==============================================================
//create an instance of a server class
SQLDMO._SQLServer srv = new SQLDMO.SQLServerClass();
//connect to the server
if(rbLocal.Checked==true)
srv.Connect(this.txtServName.Text,this.txtUserName.Text,this.txtPass.Text);
else
srv.Connect(this.cmbServList.Text,this.txtUserName.Text,this.txtPass.Text);
//create a restore class instance
SQLDMO.Restore res = new SQLDMO.RestoreClass();
//set the backup device = files property ( easy way )
res.Devices = res.Files;
//set the files property to the File Name text box
res.Files = "[" + System.IO.Path.GetTempPath()+"AlcoMateBlank.BAK" + "]";
//set the database to the chosen database
res.Database = this.txtDBName.Text;
// Restore the database
res.ReplaceDatabase = true;
res.SQLRestore(srv);
==============================================================
This code working properly if Backup file is on Local Machine but not if backup file is on another machine in a network. I am getting this error
BackupDiskFile::OpenMedia: Backup device 'C:\DOCUME~1\sachin\LOCALS~1\Temp\AlcoMateBlank.BAK' failed to open. Operating system error = 3(The system cannot find the path specified.).
Can you please suggest me eassy way of restoring database from remote PC to remote sql server which is in LAN?
Sachin Gedam
(Software Engg.)
Pune India
|
|
|
|
|
Hi.
I am trying to get a bit clearer understanding on what goes on between .net 1.1 and databases, in particular ms sql 2k and ms access.
Initially I could not quite figure out how @name in Execute1(string name) was handled by ms sql and .net because it looked to me like a undeclared variable in sql.
If I use SqlParameters against ms sql 2k, it seems that what actually happens is that .net executes the stored procedure sp_executesql on ms sql 2k.
Example (using NorthWind db on ms sql 2k in C#):
<br />
public void Execute1(string name){<br />
...<br />
command.CommandText="Select CategoryID from Categories where CategoryName like @name"; <br />
SqlParameter param=new SqlParameter ("@name",System.Data.SqlDbType.NVarChar,15);<br />
param.Value=name;<br />
command.Parameters.Add(param);<br />
...}<br />
is equal to (in regards to what ms sql recieves) :
<br />
public void Execute2(string name){<br />
...<br />
command.CommandText="exec sp_executesql N'Select CategoryID from Categories where CategoryName like @name', N'@name nvarchar(15)', @name = N'" + name +"'";<br />
...}<br />
My question is then..
Since sp_executesql do not exsist in ms access, what does the tsql look like, when using SqlParameters in a query against a ms access database ?
Is there a tool that lets me peek into what goes on between .net and ms access?
Something like ms profiler for access databases ?
Thanks
Michael Weber.
|
|
|
|
|
Hello all
using Query analyzer, i want find the logged username. Here I know in case of Query Analyzer is using Integrated windows authentication.
but how to get using Sql Server Authentication?
plz help me urgent
will be appriciated.
Ramana
-- modified at 15:10 Monday 27th March, 2006
|
|
|
|
|
Use the following in the query analyzer to get the current login and current user.
print 'This session''s current login is: '+ SUSER_SNAME()
print 'This session''s current user is: '+ SESSION_USER
To create a login that uses Sql Server Authentication, look in SQL Server Books Online online for "sp_addlogin":
--SQL Server Books Online--
sp_addlogin
Creates a new Microsoft® SQL Server™ login that allows a user to connect to an instance of SQL Server using SQL Server Authentication.
Syntax
sp_addlogin [ @loginame = ] 'login'
[ , [ @passwd = ] 'password' ]
[ , [ @defdb = ] 'database' ]
[ , [ @deflanguage = ] 'language' ]
[ , [ @sid = ] sid ]
[ , [ @encryptopt = ] 'encryption_option' ]
If this doesn't answer your question, maybe look up "Authentication Modes" in the SQL Server Books Online.
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
Hi Everyone,
I am running my program where i am using pubs database, authors table of Sql. But while updating (dataadapter.update (dataset,"authors") ,it gave me this error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.
I used try catch to catch the exception, it gave me this error:
line1 : Incorrect syntax near ','.
(I have passed parameters, passed update statement)
I have downloaded the code from this site
http://www.programmersheaven.com/2/Les_VBNET_13_p4[^]
I am putting code for your kind reference
Private Sub InitializeCommands()<br />
' Preparing Insert SQL Command<br />
dataAdapter.InsertCommand = conn.CreateCommand()<br />
dataAdapter.InsertCommand.CommandText = "INSERT INTO authors au_id, au_fname, au_lname, address VALUES @au_id, @au_fname, @au_lname, @address"<br />
<br />
AddParams (dataAdapter.InsertCommand, "au_id", "au_fname", "au_lname", "address")<br />
dataAdapter.UpdateCommand = conn.CreateCommand()<br />
dataAdapter.UpdateCommand.CommandText = _<br />
"UPDATE authors au_id = @au_id, au_fname = @au_fname, au_lname = @au_lname,address = @address WHERE au_Id = @au_Id"<br />
AddParams(dataAdapter.updateCommand, "au_id", "au_fname", "au_lname", "address")<br />
<br />
dataAdapter.DeleteCommand = conn.CreateCommand()<br />
dataAdapter.DeleteCommand.CommandText = "DELETE FROM article WHERE au_id = @au_Id"<br />
AddParams(dataAdapter.DeleteCommand, "au_Id")<br />
End Sub<br />
<br />
Private Sub AddParams(ByVal cmd As SqlCommand, ByVal ParamArray cols() As String)<br />
' Adding Hectice parameters in SQL Commands<br />
Dim col As String<br />
For Each col In cols<br />
cmd.Parameters.Add("@" + col, SqlDbType.Char, 0, col)<br />
Next<br />
End Sub<br />
<br />
Private Sub btnSave_Click(ByVal sender As System.Object, _<br />
ByVal e As System.EventArgs) Handles btnSave.Click<br />
lblLabel.Text = "Saving Changes..." <br />
Me.Cursor = Cursors.WaitCursor<br />
Dim row As DataRow = dataTable.Rows(currRec)<br />
row.BeginEdit()<br />
row("au_id") = txt1.Text <br />
row("au_fname") = txt2.Text<br />
row("au_lname") = txt3.Text<br />
row("address") = txt4.Text<br />
row.EndEdit()<br />
dataAdapter.Update(ds, "authors")<br />
ds.AcceptChanges()<br />
ToggleControls(True)<br />
insertSelected = False<br />
Me.Cursor = Cursors.Default<br />
lblLabel.Text = "Changes Saved"<br />
End Sub<br />
Thanking you and waiting for some kind replies.
Amit
|
|
|
|
|
I think the problem is you are missing the SET keyword on your update statement.
UPDATE tablename SET <column> = <value>, <column> = <value> ......
|
|
|
|
|
Looks like my reply may not be clear. Maybe I was typing too fast or my using a less than, greater than sign around the words "column" and "value" created a problem.
Anyhow - let me try again.
UPDATE tablename SET column_name = value, column_name = value, .... etc.
I believe you need to specify the SET keyword as part of the UPDATE command.
|
|
|
|
|
Thanks for your reply but i'm using set keyword near update statement. I have given the update statement and fieldnames.
Please refer my question.
Thanks again.
Amit
|
|
|
|
|
As the previous poster pointed out, your update query -"UPDATE authors au_id = @au_id, au_fname = @au_fname, au_lname = @au_lname,address = @address WHERE au_Id = @au_Id"
is missing the keyword 'Set'
it should be "UPDATE authors Set au_id = @au_id, au_fname = @au_fname, au_lname = @au_lname,address = @address WHERE au_Id = @au_Id"
Since it is missing, the sql parser detects an error at the first comma
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
Hey Thanks everyone. My Problem got solved i missed one quotes.
|
|
|
|
|
Hi
i have 2 tables T1( ID int, content ntext) and T2(ID int, content ntext)
i want to fill T2 with T1 rows.
4 some reasons i should reade T1.ID and write theme to T2 and then
read T1.Content and write theme to T2.Content. What should i do plz???
|
|
|
|
|
INSERT INTO T2
(
id,
content
)
SELECT
id,
content
FROM
T1
|
|
|
|
|
Hi,
I have a query in my stored procedure that bring back the role name and description based on the ID supplied. If it found the role, it bring back a 0. Now I only want it to create a Role instance and populate it if 0 is returned. But it moaning about the cast
intResult = (int)objCmd.Parameters["@Return_Value"].Value;
I would've liked to replced if (objDr.HasRows) with if (intResult == 0). Is the way to do it, or is there some other way?
Here is my piece of code:
using (SqlConnection objConn = new SqlConnection(PLATTERGlobals.ConnectionString))
{
using (SqlCommand objCmd = new SqlCommand("sp_Roles_GetRoleByID", objConn))
{
// Mark the command as a SPROC
objCmd.CommandType = CommandType.StoredProcedure;
// Add parameters to SPROC
AddParameterToSQLCmd(objCmd, "@RoleID", SqlDbType.Int, 4, ParameterDirection.Input, intRoleID);
// Open the connection
objConn.Open();
using (SqlDataReader objDr = objCmd.ExecuteReader())
{
//intResult = (int)objCmd.Parameters["@Return_Value"].Value;
// Check for a positive return
if (objDr.HasRows)
{
while (objDr.Read())
{
objRole = new Role();
objRole.RoleName = objDr.GetString(0);
objRole.RoleDescription = objDr.GetString(1);
}
}
}
}
}
I hope someone can help.
Regards,
ma se
|
|
|
|
|
Hello,
I am currently working on a project with SQL Server 2005 and I must say that I'm a beginner with SQL server.
I have created a new login for server, and after have created a new user for my database. After this I tryed to connect with the new user but got the following error message:
TITLE: Connect to Server
------------------------------
Cannot connect to ANDREIC-PC\SQLEXPRESS.
------------------------------
ADDITIONAL INFORMATION:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
What could be the cause for this failure?
Thank you in advance!
AndreiC
Croitoriu Andrei
andrei.croitoriu@gmail.com
|
|
|
|
|
Did you get this error in the database explorer using Visual Studio or Visual Web Developer? I got the same error when I use VWD, but this happens only every now and then. I just click on the treeview to expand my database then it asks for a password, and it works fine.
I hope this solves your problem, and I hope someone else can explain this problem to all of us.
Regards,
ma se
|
|
|
|
|
hi there,
I get an error whenever I Download my .net application to a Client , I have reports in my application and the reports won't work with an error cannot find find keycodev2.dll or invalid keycode, I tried to register this dll and it succeeded but i still have the error and my reports are not working
please helpppppppp
-- modified at 1:30 Monday 27th March, 2006
|
|
|
|
|
It seems that you have Visual Studio .NET 2003
In this case, you should create a setup project, add all Crystal merge modules to project. In Crystal_Regwiz2003 properties, expand MergeModuleProperties and enter license key (you can find license key for Crystal in about dialog of VS)
Hope that help
|
|
|
|
|
thanks but it didn't work i still have the same error, any other suggestions?
|
|
|
|
|
hai all,
i have a table named 'applcn', it conatin near 100 field
i want to alter one column to not null
for that i use the folllowing query
alter table applcn alter column txtreforg3 nvarchar not null
but it show error like
Server: Msg 8152, Level 16, State 6, Line 1
String or binary data would be truncated.
The statement has been terminated.
how i slovw this???urgent
All I ever wanted is what others have....
CrazySanker
|
|
|
|
|
Hi i believe your statement
'alter table applcn alter column txtreforg3 nvarchar not null'
does not specify the column length which its will automatically give a default length value = 1 for txtreforg3 which you already has some data more than length = 1
So i suggest you make your statement
'alter table applcn alter column txtreforg3 nvarchar(x) not null'
x = depend the max length of your data in table.
-C-?-M-
|
|
|
|
|
I have a MySQL 4.1 DB. When I am selecting from it by using ODBC driver instead of some russian characters I get only "???????? ??"
Default character set in DB is cp1251.
Is it possibly to set in Connection String which character set to use?
|
|
|
|
|
Monin D. wrote: I have a MySQL 4.1 DB. When I am selecting from it by using ODBC driver instead of some russian characters I get only "???????? ??"
Default character set in DB is cp1251.
Disclaimer,
I haven’t had to work with any language other than English.
I have noticed over the years that there are language specific ODBC drivers. Make sure you’re using the right ODBC driver for the language.
Good luck
|
|
|
|
|
Did you guys tried "Drilldown" feature in SQL Server 2005's "Reporting Services"? I implemented a report with drilldown - it works perfectly on Visual Studio 2003 Report Designer, I manage to build, render, view the report and toggle the "+" (and "-") to collapse/expand drilldown button.
However, when I tried to access the report via URL Access+Browser (IE):
http://localhost/reports/MySalesReports/sales_rpt1
Then drilldown stopped working. The "+" button is rendered, but when you click on it nothing happens. I am suspecting clientside/browser setting... anyone ran into this problem before?
Norman Fung
|
|
|
|
|
Hi, I'm investigating if it's possible to dynamically add column to selected report hosted by SQL Server's Reporting Service?
In my quest to resolve this problem I came across this article: http://www.codeproject.com/dotnet/DynamicReport.asp
Basically, the author's approach is to pass selected report a paratmer (plain old report parameter just like any other). The report toggle column property "visibility" of selected columns based on this parameter - but these columns needs to be defined ahead of time.
I'm looking for a way to truely dynamically add column to reports (rdl files loaded to Report Server). Thinking of further exploring Reporting Service Web Service Library - you can adjust web service properties, specify report paramters and retrieve report but it does not look like it will let you dynamically . Any idea? Thanks.
Norman Fung
REF:
MSDN - Reporting Services Web Services Library
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_prog_soapapi_dev_3g0y.asp
|
|
|
|
|