i hv been trying to perform insert operation on Oracle 10G database using asp.net 3.5. So far i m new to oracle and i m confused as back end queries seems different froms sql server. this code is in submit button click event:-
Dim mySource As New SqlDataSource()
mySource.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString1").ToString()
mySource.InsertCommandType = SqlDataSourceCommandType.Text
mySource.InsertCommand = "INSERT INTO PROP(ID_NO,COMP_CD,DOS)VALUES(:ID_NO,:COMP_CD,:DOS);"
well that didn't help me ...howevr i finally found some problems in query like ';' at end of query...but this new code is complete modification and working but thanks anyway.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strString As String = ConfigurationManager.ConnectionStrings("ConnectionString1").ToString()
Dim conn As New OracleConnection(strString)
Dim strQuery As String = "INSERT INTO PAYMENT_COURSE_DESC(ID_NO,COMP_CD,DOS,STATUS)VALUES(:ID_NO,:COMP_CD,:DOS,:STATUS)"
Dim command As New OracleCommand(strQuery, conn)
Dim status As Char = "P"
command.Parameters.AddWithValue(":ID_NO", TextBox1.Text)
command.Parameters.AddWithValue(":COMP_CD", DropDownList1.SelectedValue)
command.Parameters.AddWithValue(":DOS", Date.Now())
command.Parameters.AddWithValue("STATUS", status)
conn.Open()
Dim count As Integer = -1
Try
count = Convert.ToInt32(command.ExecuteScalar())
Catch ex As Exception
Label1.Text = "Due to some problem this request is not submitted"
End Try
If count = -1 Then
Label1.Text = "Due to some problem this request is not submitted"
Else
Label1.Text = "Request from Id: " + TextBox1.Text.ToUpper() & " for Course no. " + DropDownList1.SelectedItem.ToString() & " is submitted "
Button1.Enabled = False
End If
Member
2 Points
9 Posts
oracle starter
Jun 06, 2010 06:44 AM|master3g|LINK
hello everyone,
i hv been trying to perform insert operation on Oracle 10G database using asp.net 3.5. So far i m new to oracle and i m confused as back end queries seems different froms sql server. this code is in submit button click event:-
Dim mySource As New SqlDataSource()
mySource.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString1").ToString()
mySource.InsertCommandType = SqlDataSourceCommandType.Text
mySource.InsertCommand = "INSERT INTO PROP(ID_NO,COMP_CD,DOS)VALUES(:ID_NO,:COMP_CD,:DOS);"
mySource.InsertParameters.Add("ID_NO", TextBox1.Text)
mySource.InsertParameters.Add("COMP_CD", TextBox2.Text)
mySource.InsertParameters.Add("DOS", Date.Now())
Dim rowsAffected As Integer = 0
Try
rowsAffected = mySource.Insert()
Catch ex As Exception
Server.Transfer("fail.aspx")
Finally
mySource = Nothing
End Try
If rowsAffected <> 1 Then
Server.Transfer("fail.aspx")
Else
Server.Transfer("success.aspx")
End If
ConnectionString1 is in web.config
(<connectionStrings>
<add name="ConnectionString1" connectionString="Data Source=id;Persist Security Info=True;User ID=optiplex;Password=demon;Unicode=True" providerName="System.Data.OracleClient"/>
</connectionStrings>)
Windows xp sp3
Visual studio 2008(asp.net 3.5)
oracle 10G
Table Name PROP
Columns ID_NO(CHAR),COMP_CD(NUMBER),DOS(CHAR)
HELP plz
Contributor
2774 Points
860 Posts
Re: oracle starter
Jun 06, 2010 06:10 PM|andrewjboyd|LINK
You don't set the ProviderName property for the SqlDataSource, check out
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.providername(v=VS.80).aspx
================================================
Why catch a fish to feed someone, when you can teach them to fish and they can feed themselves
Member
2 Points
9 Posts
Re: oracle starter
Jun 07, 2010 05:54 AM|master3g|LINK
well that didn't help me ...howevr i finally found some problems in query like ';' at end of query...but this new code is complete modification and working but thanks anyway.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strString As String = ConfigurationManager.ConnectionStrings("ConnectionString1").ToString()
Dim conn As New OracleConnection(strString)
Dim strQuery As String = "INSERT INTO PAYMENT_COURSE_DESC(ID_NO,COMP_CD,DOS,STATUS)VALUES(:ID_NO,:COMP_CD,:DOS,:STATUS)"
Dim command As New OracleCommand(strQuery, conn)
Dim status As Char = "P"
command.Parameters.AddWithValue(":ID_NO", TextBox1.Text)
command.Parameters.AddWithValue(":COMP_CD", DropDownList1.SelectedValue)
command.Parameters.AddWithValue(":DOS", Date.Now())
command.Parameters.AddWithValue("STATUS", status)
conn.Open()
Dim count As Integer = -1
Try
count = Convert.ToInt32(command.ExecuteScalar())
Catch ex As Exception
Label1.Text = "Due to some problem this request is not submitted"
End Try
If count = -1 Then
Label1.Text = "Due to some problem this request is not submitted"
Else
Label1.Text = "Request from Id: " + TextBox1.Text.ToUpper() & " for Course no. " + DropDownList1.SelectedItem.ToString() & " is submitted "
Button1.Enabled = False
End If
End Sub