回 帖 发 新 帖 刷新版面

主题:问题

请问哪位高手懂得将文本框中的内容读到SQL Server 2000数据库中??
给出语句的加满分
谢谢!!!

回复列表 (共5个回复)

沙发

在你的命令按钮添加声明
cm.Parameters .Add ("@post_id",SqlDbType.Char);
然后把文本的值赋给参数值

cm.Parameters ["@post_id"].Value =TextBox1.Text.Trim();

板凳

前端声明:
Public mOraConnect As OracleInProcServer.OraSession
    Public mOraSession As OracleInProcServer.OraDatabase
    Dim SAVE As String
Dim oDys As OracleInProcServer.OraDynaset
控制台:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mOraConnect = CreateObject("OracleInProcServer.XOraSession")
        mOraSession = mOraConnect.DbOpenDatabase("datasource", "user" + "/" + "password", 1)
        mOraConnect.DbBeginTrans()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SAVE = ""
        SAVE = SAVE & " INSERT INTO 表名(字段名)"
        SAVE = SAVE & " VALUES( '"& TextBox1.Text & "')"
                System.Diagnostics.Debug.Write(SAVE)
        mOraSession.ExecuteSQL(SAVE)
        mOraSession.CommitTrans()

3 楼

imports system.data
imports system.data.sqlclient

Public constr As String = "provider=microsoft.jet.oledb.4.0;data source=e:\VB.NETziliao\publicdatabase\db1.mdb"
    Public mycon As New OleDb.OleDbConnection(constr)

dim str1,str2 as string
str1="insert into 表名 (“字段名“
str2="values('"& textbox1.text &"'
str1 &= (")  " & str2 & ") ")
Dim com As New OleDbCommand(str1, mycon)
                mycon.Open()
                com.ExecuteNonQuery()
                mycon.Close()

4 楼

好文章值得看一下!

5 楼

好文章值得看一下!

我来回复

您尚未登录,请登录后再回复。点此登录或注册