|
below given a database structure. in table A if any formid insert then table B auto insert formID, each Distinct EmpID
----- row insert manually----------
===== row insert Automatically========
Table A
FormID FormName
1 Department
2 Employee
-----3(FormID)------Location(FormName)---new insert row
Table B
FormID EmpID
1 1
2 1
====3(FormID)===1(EmpID)======>>autoinsert through trigger
1 2
2 2
=====3(FormID)===2(EmpID)======>>autoinsert through trigger
1 3
2 3
=====3(FormID)===3(EmpID)======>>autoinsert through trigger
any one help me through insert trigger on Tble A
|
|
|
|
|
Could you please explain what you want in a clearer fashion? I must admit that this is a rather confusing description.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
scon.ConnectionString = <br />
"integrated security= true ;" +"initial catalog =my;" + <br />
"data source =BUDDHIKA\\SQLEXPRESS;";<br />
<br />
<br />
scon.Open();<br />
<br />
sc.Connection = scon;<br />
<br />
sc.CommandText = "create login " + textBox6.Text +<br />
" with password ='" + textBox7.Text + "' ";<br />
<br />
sc.CommandText += "exec sp_addsrvrolemember " <br />
+ textBox6.Text+ ",sysadmin ";<br />
<br />
sc.CommandText += "create user " + textBox6.Text + " from login " <br />
+ textBox6.Text + " use my ";<br />
<br />
sc.CommandText += "execute sp_addrolemember " <br />
+ comboBox3.SelectedItem.ToString() + "," + textBox6.Text <br />
+ " use my";<br />
<br />
SqlDataReader sd = sc.ExecuteReader();<br />
<br />
sd.Close();<br />
<br />
sc.CommandText = "insert into my.dbo.sys_usr values <br />
('" + comboBox4.SelectedItem.ToString() + "','" + textBox1.Text <br />
+ "','" + textBox46.Text + "','" + textBox2.Text + "','" <br />
+ comboBox2.SelectedItem.ToString() + "','" <br />
+ Box3.SelectedItem.ToString() + "')";<br />
<br />
sd = sc.ExecuteReader();
when i run this code get an error
Incorrect syntax near the keyword 'with'.
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
|
|
|
|
|
prasadbuddhika wrote: sc.CommandText = "create login " + textBox6.Text +
" with password ='" + textBox7.Text + "' ";
try to replace with
<br />
sc.CommandText = "create login " + textBox6.Text +<br />
" with [password] ='" + textBox7.Text + "' ";
I Love SQL
|
|
|
|
|
What is wrong with this code is the huge potential for someone to inject SQL into your database. You should look at paramterising this.
|
|
|
|
|
Apart from leaving you wide open to SQL Injection attacks, the variable names are really bad. What would you expect if I swapped textBox46 and textBox2 around here? How could you tell when looking at the code?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
Hi
I am getting following error on connection string in xmlbulkload:
"QueryInterface for interface SQLXMLBULKLOADLib.ISQLXMLBulkLoad failed."
Thanks
Hardik Panchal
|
|
|
|
|
I got the solution.
thanks
Hardik Panchal
|
|
|
|
|
Now, if you post your solution to your problem, I'll give it a 5 vote.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I create the one thread and call my bulk upload method from that thread.
which is work for me. before i not use the thread which is not working in my new application but working in other application.
Here is the code.
Public objBulkthread As System.Threading.Thread
If Not IsNothing(objBulkthread) Then
If Not objBulkthread.IsAlive Then
objBulkthread = New System.Threading.Thread(AddressOf objGeneral.UploadXmlBulk)
objBulkthread.ApartmentState = Threading.ApartmentState.STA
objBulkthread.Start()
End If
Else
objBulkthread = New System.Threading.Thread(AddressOf objGeneral.UploadXmlBulk)
objBulkthread.ApartmentState = Threading.ApartmentState.STA
objBulkthread.Start()
End If
Thanks
Hardik Panchal
|
|
|
|
|
Hi, would you please help how to solve it ?
The following is my sql query.
1.
Select RegionCode, count(CountryCode)
From Country
Where RegionCode ='NorthAmerica'
Group by RegionCode
2.
Select RegionCode, count(CountryCode)
From Country
Where RegionCode ='SouthAmerica'
Group by RegionCode
First query return like this
NorthAmerica 5
Second query return like this
SouthAmerica 2
If I use UNION, it combine as rows
NorthAmerica 5
SouthAmerica 2
What I want is
NorthAmerica SouthAmerica
5 2
How can I combine the results ?
Thanks in advance,
RB
|
|
|
|
|
If you are using SQL Server 2005, take a look at the Pivot command.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks for your help Pete.
But, I don't know how to use PIVOT to get my result.
Would you please show me some good samples ?
Thanks,
|
|
|
|
|
Hi everybody,
I want to retrieve the databse schema.database is in sql server2005.The language is c#.please send me some reading related meterial.
Regards,
chanzeb chaudhary.
chanzeb_chaudhary@hotmail.com
|
|
|
|
|
Here[^] you go. This is a database agnostic way of retrieving information about database schemas.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thanks alot. .....
|
|
|
|
|
Hi there,
I am new to sql server 2005 can somebody tell me is there any sql command that returns all databases hosted on SQL server 2005.
Mujtaba
"If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
|
|
|
|
|
sp_databases - This [system stroed procedure] return's all databases that reside in an instance of Microsoft SQL Server.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
hi
this is available in sql 2000 also
sp_helpdb
get back for more info.
|
|
|
|
|
OK thanx buddies. So nice of u.
Mujtaba
"If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
|
|
|
|
|
through my application i craete a login int the sql server(express) and then i created a user using login create in the above .. in the sql server it shows the login and user i created. but when login into sql server using the created (above) user name and password it says
" login failed for user 'user01'.The user is not associated with a trusted sql server connection. Microsoft sql server ,Error 10452.
could anyone explain me the reason and the solution..
|
|
|
|
|
Please check the credentials given in the connectionString of web.config
Intelligence is measured by common sense not by how many scholarly books you read.
|
|
|
|
|
The problem is related to the fact that when you installed SQLEXPRESS, it only enabled Windows Authentication. What you need to do is to enable both Windows and SQL Authentication modes. If you have a tool like Management Studio, just login to the server with Windows Authentication, then right-click on the SQLEXPRESS instance. From the menu that appears click Properties. You will find a number of Server Properties, select the Security page. From this page change Server Authentication to 'SQL Server and Windows Authentication mode'. Click OK. That should solve the problem you are experiencing.
|
|
|
|
|
ok, here is the code:
Private Sub CreateProcedure(ByVal con As SqlClient.SqlConnection)
Dim curRowIndex As Integer = ((GetCurPageIndex() * RowsPerPage) + 1)
If curRowIndex > GetTotalRowCount() Then
mCurPageIndex = NumPagesAvailable()
curRowIndex = GetTotalRowCount()
End If
Dim createProcedureSQL As String = "CREATE PROCEDURE [dbo].[PageResultsProcedure]"
createProcedureSQL &= "AS" & vbCr
createProcedureSQL &= "DECLARE @FirstID INT, @StartRow INT" & vbCr
createProcedureSQL &= "SET ROWCOUNT " & curRowIndex & vbCr
createProcedureSQL &= "SELECT @FirstID = " & TablePKName & " FROM " & TableName & " " & WhereSegment & vbCr
createProcedureSQL &= "SET ROWCOUNT " & RowsPerPage & vbCr
createProcedureSQL &= "SELECT " & ColumnsToReturn & " FROM " & TableName & CStr(IIf(WhereSegment = "", " WHERE ", " " & WhereSegment & " AND ")) & TablePKName & " >= @FirstID" & vbCr
createProcedureSQL &= "ORDER BY " & TablePKName & vbCr
createProcedureSQL &= "SET ROWCOUNT 0"
Dim cmd As SqlClient.SqlCommand
cmd = con.CreateCommand
cmd.CommandText = createProcedureSQL
con.Open()
cmd.ExecuteNonQuery()
con.Close()
cmd.Dispose()
cmd = Nothing
End Sub
This code is part of a procedure to allow paging a data table...the question is; I need a way of doing this, but being able to sort the results by a given column that is not guaranteed to have unique values in the table...Any Ideas? Thanks in advance for any help.
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|